Skip to content

GitHub Action to automatically rebase PRs

License

Notifications You must be signed in to change notification settings

mitchwu/rebase

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub action to automatically rebase PRs

Build Status

After installation simply comment /rebase to trigger the action:

rebase-action

Installation

To configure the action simply add the following lines to your .github/workflows/rebase.yml workflow file:

on: 
  issue_comment:
    types: [created]
name: Automatic Rebase
jobs:
  rebase:
    name: Rebase
    if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
    runs-on: ubuntu-latest
    steps:
    - name: Checkout the latest code
      uses: actions/checkout@v2
      with:
        fetch-depth: 0
    - name: Automatic Rebase
      uses: cirrus-actions/[email protected]
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Restricting who can call the action

It's possible to use author_association field of a comment to restrict who can call the action and skip the rebase for others. Simply add the following expression to the if statement in your workflow file: github.event.comment.author_association == 'MEMBER'. See documentation for a list of all available values of author_association.

Running multiple GitHub Actions workflows

If you have another workflow setup that for example executes unit tests, and that workflow is a required status check that needs to pass before merging, you may find the check in "waiting" status after /rebase. Unfortunately, that's a current Actions limitation, see this community post and/or #65 for more details.

However, one possible workaround is to setup your test workflow to run also on pull request review events like:

on: [push, pull_request_review]

Then for example approving a code review will start, run and finish the test workflow and you'll be able to merge the pull request (if the check passes).

GitHub can also optionally dismiss an existing review automatically after rebase, so you'll need to re-approve again which will trigger the test workflow. Set it up in your repository Settings > Branches > Branch protection rules > Require pull request reviews before merging > Dismiss stale pull request approvals when new commits are pushed.

About

GitHub Action to automatically rebase PRs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 82.0%
  • Dockerfile 18.0%