Suppose I have these branches:
- main
- feature1
- feature2
In my github actions I need to know what is number of times I have pushed into a branch or I have manually triggered the actions on that branch
With ${{ github.run_attempt }}
:
each time I push I get the number 1
. I only get a new number if I manually rerun the job
with ${{ github.run_number }}
:
each time I push to this repository in any branch it is incremented.
so suppose I push to the main or feature1 or feature2 branches, it is added to this number
But if I manually trigger the pipeline, it is not added to it
I need a variable that if I push to any branch for the first gives me the number 1
and if I push again/or trigger manually it adds to it.
so suppose I push 2 times into the feature1 branch and run it manually once and then push again, it gives me the number 4 in the next push or manual trigger, independent of what has happened on the other branches or their pipelines.
I need this number because on my docker registry my path is like this:
docker-reg-host/project-name/branch-name:the-number-from-above
the-number-from-above is the number of times the pipeline is triggered manually or by pushing, in this specific branch not other branches
I want to add a new tag each time that is this number
I can make the requirement simpler and request a variable that returns run_number of a specific branch
then I am going to choose this strategy
docker-reg-host/project-name/branch-name:branch_run_number-run_attempt
But at least I need to know how many times I have pushed to this specific branch