Get the branch name

Pardon if this has been discussed before. But would it be possible to add a default ENV for the active branch name that triggered the action? I understand that GITHUB_REF can achieve the same thing through intermediate manipulation, however that introduces the chance of user error. This seems like a good default var for the common task of pushing builds keyed by branch name.

1 Like

As the GitHUB_REF is in different forms for different events, for example: 

GitHUB_REF of pull request event  is PR merge branch refs/pull/:prNumber/merge;  and when the workflow is triggered by pushing a tag, the GitHUB_REF is refs/tags/:tagname . 

So branch name env could not include all the scenarios.  

There is a ticket shows some ways to extract branch name from GITHUB_REF: 

 https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions

If you still want a defaulf variable for branch name, you could try sharing the idea  in the  Feedback form for GitHub Actions.