/update-pr-branch

Automatically update PR branch that match the criteria. Designed to work with the Github `auto-merge` feature.

Primary LanguageJavaScriptMIT LicenseMIT

Update PR Branch Action

GitHub Actions Coverage Status

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

When do you need this action

You may consider to use this action if you:

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.

Update branch

Inputs

token

Required

The personal access token.

Need to note, you can't use GITHUB_TOKEN because of this limitation

required_approval_count

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.

require_passed_checks

Optional

Default: true

The action will skip PRs that have failed checks.

Example usage

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

Development

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.