iaingalloway / devcontainers

Pre-built devcontainer images
MIT License
0 stars 0 forks source link

Need to figure out a way of not having github run two actions when I tag #6

Closed iaingalloway closed 1 year ago

iaingalloway commented 1 year ago

This commit:

https://github.com/iaingalloway/gitversion-prototype/commit/81273623b0837cf86af11b62abd5795460aa50de

Is tagged v1.0.0

I created it with

> git commit -m "Add gitversion.yaml"
> git t v1.0.0
> git push --follow-tags 
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 20 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 431 bytes | 431.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:iaingalloway/gitversion-prototype.git
   08084c2..8127362  main -> main
 * [new tag]         v1.0.0 -> v1.0.0

Workflows were queued twice:

https://github.com/iaingalloway/gitversion-prototype/actions/runs/6676439638 https://github.com/iaingalloway/gitversion-prototype/actions/runs/6676439672

And two images were created with different SHAs:

https://github.com/iaingalloway/gitversion-prototype/pkgs/container/gitversion-prototype/142030062?tag=1.0.0 https://github.com/iaingalloway/gitversion-prototype/pkgs/container/gitversion-prototype/142030077?tag=1.0.0.main--14ef668

They both have the same version:

> docker run --rm -it ghcr.io/iaingalloway/gitversion-prototype:1 cat version.txt
1.0.0

> docker run --rm -it ghcr.io/iaingalloway/gitversion-prototype:1.0.0.main--14ef668 cat vers
ion.txt
1.0.0

So they're tagged correctly, but I don't think I want two builds here.

iaingalloway commented 1 year ago

Ignoring all tags results in the build not running at all:

on:
  push:
    tags-ignore:
      - '*'
  pull_request:
  workflow_dispatch:

See: https://github.com/iaingalloway/gitversion-prototype/commit/721342b2459ef85d8cd0761b3da7feee2a7ad36d

iaingalloway commented 1 year ago

Works if I specify both tags-ignore and branches.

on:
  push:
    branches:
      - '*'
    tags-ignore:
      - '*'
  pull_request:
  workflow_dispatch:

Seems like quite an odd default behaviour. The docs mention this: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore

If you define only tags/tags-ignore or only branches/branches-ignore, the workflow won't run for events affecting the undefined Git ref.

But it could be clearer.