1

I have a GitHub action workflow where I am doing a merge of various different source branches into target branch main.

When I look at GITHUB_REF it contains main branch.

How do I get the name of the source branch?

zrrbite
  • 1,180
  • 10
  • 22
vy218
  • 707
  • 1
  • 8
  • 15
  • Does this answer your question? [How to get branch name on GitHub action?](https://stackoverflow.com/questions/60300169/how-to-get-branch-name-on-github-action) – SwissCodeMen Oct 19 '20 at 21:36
  • Thanks for the link - I had already read this as post as part of my search, it doesn’t answer my question since it shows how to get the target branch name - I want to get the source branch name. – vy218 Oct 20 '20 at 03:54

1 Answers1

0

To have access to all the properties of the event that triggered the action, you can look-up the path in the variable $GITHUB_EVENT_PATH (it's a json describing the event).

You can then access it using ${{ github.event.<the path in the json> }}. In your case ${{ github.event.pull_request.base.ref }} should have the info you are looking for.

Potential duplicate with this question?

Lucas
  • 1,171
  • 9
  • 21