How to get the target branch name using pull_request_review event on github actions #27154
-
I have multiple jobs in github actions. I want to run jobs based on specific branches only on pull_request_review event. I tried using So my question is how to get target branch name? I created PR from branch “latest” to “master” I tried following, but does not work for me. It skips the first job Job1
Then I tried different approach and that also doesn’t work: job1.yaml
job2.yaml
So after trying these steps, none of them worked. Now I am looking for different approach of how to get target branch name and then use conditions based on branches and then run the jobs. If I can use the same approach then how to achieve it? If anyone has suggestion how to achieve this using same or different approach then please answer. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Hi @so-amuk, For pull_request_review event, please use ${{ github.event.pull_request.base.ref }} to get the target branch name. The value comes from Github Context, for different event, the value name and location could be different. Please use below code to export the context:
Follow the structure of the context, you can find the target branch name.
Please check my workflow for your reference. weide-zhou/Ticket2Contribute to weide-zhou/Ticket2 development by creating an account on GitHub. Thanks |
Beta Was this translation helpful? Give feedback.
-
@weide-zhou Thanks for your valuable answer. It worked for me. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the hint.
|
Beta Was this translation helpful? Give feedback.
-
In our case, it's even not base, but As far as I can see, it's not in the official documentation yet? |
Beta Was this translation helpful? Give feedback.
Hi @so-amuk,
For pull_request_review event, please use ${{ github.event.pull_request.base.ref }} to get the target branch name.
The value comes from Github Context, for different event, the value name and location could be different. Please use below code to export the context:
Follow the structure of the context, you can find the target branch name.
So your code can be fixed as below: