0

I committed some changes, then I tagged them:

git tag -f 0.9.5.0

Then I git push and a workflow starts. I need to obtain and check this tag in the workflow, and I can't find a way to do that.
echo $GITHUB_REF prints this:

refs/heads/master

And echo "github.ref_name=${{github.ref_name}}" prints this:

echo "github.ref_name=master"

So neither method detects the tag. Why is it, and how can I get my 0.9.5.0 tag?

Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • You haven't pushed your tag tho. You're looking at runs for your push on master, but only tag-triggered pushes have their tag name in `github.ref_name`. – CodeCaster Mar 14 '23 at 14:04
  • @CodeCaster: no, this answer doesn't explain why the tag is not visible to the runner. Are you saying this is how `git` works? Tags are not visible on the branch where the tagged commit is? What do you mean I haven't pushed my tag, how do I push it then? – Violet Giraffe Mar 14 '23 at 14:08
  • It definitely does answer that question. Read again: you haven't pushed the 0.9.5.0 tag to your [file-commander repository](https://github.com/VioletGiraffe/file-commander/tags), you have just pushed your master branch. The `github.ref_name` will only be set to the tag name for a tag push; for a push on a branch it will contain the branch name. See [How do you push a tag to a remote repository using Git?](https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git) for that. – CodeCaster Mar 14 '23 at 14:15
  • @CodeCaster: thank you, this does answer my question, could you post an answer? P. S. `git` is super weird, I don't get how this was deemed the desired or even acceptable behavior. – Violet Giraffe Mar 14 '23 at 14:31

0 Answers0