Run Action on PR When Target Branch is Updated

Hello,

We have had a situation on our team where a check is run on every PR targeting master that can be misleading.
It is possible for the check to pass when run on the synchronize event type of the PR, then a different PR is merged to master which would make the check fail, but the first PR is still merge-able because the check has already passed on a previous HEAD of master.

Is it possible to run a check on PRs targeting master on every push to master?

Thanks

Hi @tymokvo,

You can create a branch protection rule for master branch, check the option ‘Require branches to be up to date before merging’. This ensures that the branch is tested with the latest code on the base branch.

If base branch is updated by another PR, it will hint out-of-date and cannot merge the 2nd PR.

Then you need to close the PR and re-create the PR, merge if all passed.

Please refer to the official doc for more details.

Thanks

Thank you for the tip! Does this work if the checks are run conditionally? We only run certain checks based on the paths parameter, so forcing a certain check as a predicate for all feature branches may not be possible.

Hi @tymokvo,

You have to enable at least one status check otherwise the option won’t work.

It’s not supported to run a check on PRs targeting master on every push to master. You have to create a new pull request then it will compare with new traget branch content.

Thanks