GitHub Actions - tags vs branches confusion

I have a project with only a single main branch for which a workflow is triggered upon a push of a tag.

When creating a badge GitHub actions is treating the tag as a branch but the tag was not on a branch it was on ‘master’.

So the following will not work:

https://github.com/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_FILE_PATH>/badge.svg

Yet this will:

https://github.com/<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_FILE_PATH>/badge.svg?branch=<BRANCH_NAME>

Also on the Actions screen there is a “Filter by branch” which puts the tag under the list of branches yet I have no branch of the tag name.

Can anyone explain this behavior?

Hi @cmh-dev

Glad to see you in Github Community Forum!

When you push tag to trigger the workflow, the ref is ‘refs/tags/v0.1’ not master, hence you need to add ‘branch’ parameter.

https://github.com/<OWNER>/<REPOSITORY>/workflows/WORKFLOW_NAME/badge.svg?branch=<BRANCH_NAME>

Also on the Actions screen there is a “Filter by branch” which puts the tag under the list of branches yet I have no branch of the tag name.

Yes, it will list branches, and tags. You can check in the tag tab:
image

Please refer to the official doc for more details.

Thanks