Skip to content

Rebase PR

Rebase PR #5545

Workflow file for this run

name: Rebase PR
on:
issue_comment:
types: [created]
permissions:
id-token: write
contents: write
pull-requests: write
jobs:
rebase:
if: >-
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/rebase') &&
(github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'COLLABORATOR')
uses: ./.github/workflows/reusable-claude-on-pr.yaml
with:
command-name: rebase
status-message: "Rebasing PR onto main"
claude-prompt: >-
Rebase this branch onto the latest upstream main and force push.
You are running in CI. Force push with --force-with-lease when done without asking for confirmation.
The 'origin' remote may point to a fork; the workflow has already added an 'upstream' remote for fork PRs.
Steps:
1) Run 'git remote -v' to identify remotes
2) Determine the main-branch remote: if 'upstream' remote exists use 'upstream', otherwise use 'origin'
3) git fetch <chosen-remote> main
4) git rebase <chosen-remote>/main
5) If there are conflicts, resolve them while preserving the intent of the PR changes
6) git push --force-with-lease origin
If the push fails with a permission or authentication error, post a PR comment using
'gh pr comment' explaining that the rebase succeeded locally but the push failed because
the PR does not allow maintainer edits, and ask the author to enable 'Allow edits from
maintainers' and retry /rebase. Do NOT report success if the push failed.
Report what was done.
max-turns: 50
allowed-tools: "Bash Read Write Edit Grep Glob"
secrets: inherit