Event pull_request_review restrict PR base branch

For event pull_request_review is it possible to trigger workflow only when the review is submitted on a PR whose base branch is master.

This workflow shouldn’t get triggered on reviews on any other branch other than master.

@nikhilaii93 - It’s possible to limit the types of activity that will trigger a workflow run using the types field:

https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#onevent_nametypes

Here’s an example workflow that triggers on the pull_request_review event only when a review is submitted:

on:
  pull_request_review:
    types: [submitted]

In the job, you can use the if conditional at the job level and the github context to run said job only if the base ref is master:

https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idif

https://help.github.com/en/github/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#github-context

Here’s an example:

jobs:
  job1:
    if: github.base_ref == 'master'

Hope this helps!

2 Likes