Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

Rebase Pulls

Actions
Rebase pull requests in a repository
v1.0.6
Star (47)

Rebase

CI GitHub Marketplace

A GitHub action to rebase pull requests in a repository.

Usage

The default behaviour of the action with no configured inputs is to check the current repository for rebaseable pull requests and rebase them. Pull requests from forks are rebaseable only if they allow edits from maintainers.

      - uses: peter-evans/rebase@v1

Periodically rebase all pull requests

The simplest way to use this action is to schedule it to run periodically.

name: Rebase
on:
  schedule:
    - cron:  '0 0 * * *'
jobs:
  rebase:
    runs-on: ubuntu-latest
    steps:
      - uses: peter-evans/rebase@v1

Rebase all pull requests on push to the base branch

name: Rebase
on:
  push:
    branches: [main]
jobs:
  rebase:
    runs-on: ubuntu-latest
    steps:
      - uses: peter-evans/rebase@v1
        with:
          base: main

Rebase slash command

Use the following two workflows and a repo scoped PAT to add a /rebase slash command to pull request comments. The slash-command-dispatch action makes sure that the command is only executable by users with write access to the repository.

name: Slash Command Dispatch
on:
  issue_comment:
    types: [created]
jobs:
  slashCommandDispatch:
    runs-on: ubuntu-latest
    steps:
      - name: Slash Command Dispatch
        uses: peter-evans/slash-command-dispatch@v1
        with:
          token: ${{ secrets.PAT }}
          commands: rebase
          permission: write
          issue-type: pull-request
name: rebase-command
on:
  repository_dispatch:
    types: [rebase-command]
jobs:
  rebase:
    runs-on: ubuntu-latest
    steps:
      - uses: peter-evans/rebase@v1
        id: rebase
        with:
          head: ${{ github.event.client_payload.pull_request.head.label }}
      - name: Add reaction
        if: steps.rebase.outputs.rebased-count == 1
        uses: peter-evans/create-or-update-comment@v1
        with:
          token: ${{ secrets.PAT }}
          repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
          comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
          reaction-type: hooray

Action inputs

Name Description Default
token GITHUB_TOKEN or a repo scoped PAT. The workflow scope may also be required if rebasing pull requests containing changes to workflows under .github/workflows. GITHUB_TOKEN
repository The target GitHub repository containing the pull request. github.repository (Current repository)
head Filter pull requests by head user or head organization and branch name in the format user:ref-name or organization:ref-name. For example: github:new-script-format or octocat:test-branch.
base Filter pull requests by base branch name. Example: gh-pages.

Target other repositories

You can rebase requests in another repository by using a repo scoped PAT instead of GITHUB_TOKEN. The user associated with the PAT must have write access to the repository.

This example targets multiple repositories.

name: Rebase
on:
  schedule:
    - cron:  '0 0 * * *'
jobs:
  rebase:
    strategy:
      matrix:
        repo: ['my-org/repo1', 'my-org/repo2', 'my-org/repo3']
    runs-on: ubuntu-latest
    steps:
      - uses: peter-evans/rebase@v1
        with:
          token: ${{ secrets.PAT }}
          repository: ${{ matrix.repo }}

License

MIT

Rebase Pulls is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Rebase pull requests in a repository
v1.0.6

Rebase Pulls is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.