I need to have a workflow that only runs on pull request reviews to the production
branch but currently they are running on all pull request reviews.
I tried all of these options:
on:
pull_request_review:
types: [submitted, edited]
branches:
- production
on:
pull_request_review:
types: [submitted, edited]
branches: [production]
on:
pull_request_review:
types: [submitted, edited]
branches: production
and the workflow gets executed when there's a pull request review from
feature-branch
to main
(not touching production
) at all.
What am I missing? How do you do this?
In GitHub Actions: run step only for certain pull request base branches, there's this workflow:
name: my-workflow
on:
push:
branches:
- develop
pull_request:
branches:
- develop
- main
types:
- closed
and the answer assumes that branches:
just works correctly. There's no mention about what else to do to make branches:
work. I already added a branches:
to my workflow and it's being ignored.
The branches
and branches-ignore
filters work on the following events:
The pull_request_review
is not among those. You can use the if
to conditionally execute jobs. In this case, check if the "base" (merge target) is "production":
name: PR_review
on:
pull_request_review:
types: [submitted, edited]
jobs:
test:
if: ${{ github.event.pull_request.base.ref == 'production' }}
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo ${{ github.event_name }}
echo ${{ github.ref }}
echo ${{ github.event.pull_request.head.ref }}
echo ${{ github.event.pull_request.base.ref }}
Now when a review is submitted to another branch, this workflow will run - but its job will be marked as "skipped".