I want to access the Pull Request number in a Github Actions workflow. I can access the GITHUB_REF
environment variable that is available. Although on a Pull Request action it has the value: refs/pull/125/merge
. I need to extract just the 125
.
I have found a similar post here that shows how to get the current branch using this variable. Although in this case, what I am parsing is different and I have been unable to isolate the Pull Request number.
- I have tried using
{GITHUB_REF##\*/}
which resolves tomerge
- I have also tried
{GITHUB_REF#\*/}
which resolves topull/125/merge
I only need the Pull Request number (which in my example is 125)