Automatically update the PR branch
The job of the action is to help click "Update branch" button for you. Designed to work with the auto-merge
and "Require branches to be up to date before merging" options. It will update the newest open PR that match the below conditions
- The PR has the
auto-merge
option enabled - The PR has 2 approvals and no changes-requested review (configurable)
- The PR has all checks passed (configurable)
- The PR branch has no conflicts with the base branch
- The PR branch is behind the base branch
You may consider to use this action if you:
- Have enabled the
auto-merge
feature in your repo. - Have checked the "Require branches to be up to date before merging" checkbox for protected branches. See more Require status checks before merging
Because of #2, even you have enabled auto-merge
for a PR, the PR won't be automatically merged if the PR branch is behind the base branch, for example someone else merges another PR before your PR passes all CI checks. See the screenshot as below.
Required
Need to note, you can't use GITHUB_TOKEN
because of this limitation
Required
Default: 2
The action will skip PRs that have less approvals than required_approval_count
.
We could retrieve this value from the repo settings through an API call but that will incur one more request. GitHub has rate limit on API usage of GitHub actions.
Optional
Default: true
The action will skip PRs that have failed checks.
name: PR update
on:
push:
branches:
- 'master'
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- name: Automatically update PR
uses: adRise/update-pr-branch@VERSION_YOU_WANT_TO_USE
with:
token: ${{ secrets.ACTION_USER_TOKEN }}
required_approval_count: 2
require_passed_checks: false
Replace the VERSION_YOU_WANT_TO_USE
with the actual version you want to use, check the version format here
yarn
# this compile index.js to dest/init.js for running
yarn build
Note: You need to run yarn build
before commit the changes because when the action only use the compiled dest/index.js
.