Skip to content

How to get the target branch name using pull_request_review event on github actions #27154

Answered by weide-zhou
so-amuk asked this question in Actions
Discussion options

You must be logged in to vote

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:

      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"

Follow the structure of the context, you can find the target branch name.
So your code can be fixed as below:

name: Github actions
on: 
    pull_request_review:
      types: [submitted]
jobs:
  Job1:
    name: Job1
    runs-on: ubuntu-latest
    if: github.event.pull_request.base.ref =…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants