Making PR check actions run again when base branch is pushed

Hi,

I’m trying to figure out how to make actions that run on: [pull_request] run again when the base branch of a PR is pushed.

The documentation seems to suggest that this should just happen because it’s set to run on the synchronize action by default, but that doesn’t seem to be happening. I also tried manually enabling it for the synchronize action, but that didn’t help either.

Am I missing something?

Thanks,

Sauyon

Hi @sauyon ,

‘push’ on base branch will not trigger the pull request event. 

The commit from base branch will not be added into the PR commit list, that’s why ‘pull_request:synchronize’ is not triggered. However commit on source branch will be.

As an alternative, you can close current PR and create a new pull for check runs. Please check rest api doc for more details. Code sample as below.

name: recreatePR
on: [push]
# add type 'reopended' for pull request event in source branch.
jobs:
  job1:
    runs-on: [ubuntu-latest]
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - name: close current PR
        run: |
          curl --request PATCH \
          --url https://api.github.com/repos/${{ github.repository }}/pulls/34 \
          --header 'authorization: Bearer ${{ secrets.PAT3 }}' \
          --data '{"state": "closed"}'
      - name: recreate a pull request
        run: |
          curl --request POST \
          --url https://api.github.com/repos/${{ github.repository }}/pulls \
          --header 'authorization: Bearer ${{ secrets.PAT3 }}' \
          --data '{
            "title": "New Pull request",
            "body": "Please pull these awesome changes in!",
            "head": "B108", # source branch
            "base": "master" # base branch
          }'
1 Like

We would like this feature as well. Being able to force a re-run when the base changes would allow us to catch breaking changes due to other PR merges. This is really needed before we could consider using Github actions on a larger scale. Without it we risk getting a broken main branch, which is unacceptable.