How to get branch name like "main", "develop" on Windows VM?

Hi,

For branches that have a prefix, I use the action Dreamcodeio/whats-the-pr-branch@master and it works well.

However, I have failed to find a way go get the branch name when a change is done on “main”, “master”, “develop”. The existing actions and community help are mostly for non-Windows virtual machines.

Thank you

Not sure if I understand the problem. That action is specifically designed to remove prefixes, but your examples don’t have one. Can’t you simply use ${{ github.head_ref }}? Is this about pull requests at all?

Note that the action uses the environment variable GITHUB_HEAD_REF, which is only set for forked repositories according to the docs.

For the ref that triggered a workflow run, there is ${{ github.ref }}, but beware, it has either refs/heads/ or refs/tags/ as prefix, followed by the branch or tag name depending on the event trigger.

Thank you. I found out about github.ref and I could parse it! Case close.