Skip to content

ci(workflow): auto-rebase stacked PRs on merge#133

Merged
sbalabanov merged 1 commit into
mainfrom
preetam/ci-rebase
Mar 9, 2026
Merged

ci(workflow): auto-rebase stacked PRs on merge#133
sbalabanov merged 1 commit into
mainfrom
preetam/ci-rebase

Conversation

@behinddwalls
Copy link
Copy Markdown
Collaborator

@behinddwalls behinddwalls commented Mar 9, 2026

Summary

When a PR in a stack is merged (squash or rebase), GitHub retargets the
next PR's base to main but doesn't rebase the branch — leaving stale
parent commits in the diff. This workflow automates the fix:

  • Triggers on PR merge, finds child PRs stacked on the merged branch
  • Rebases each child onto the merged PR's base using git rebase --onto
    to replay only the child's own commits
  • Walks the full chain recursively to any depth (PR2 → PR3 → PR4...)
  • On conflict: leaves a comment with manual fix instructions, stops chain
  • Deletes the merged branch after rebasing (replaces GitHub auto-delete)

When a PR in a stack is merged (squash or rebase), GitHub retargets the
next PR's base to main but doesn't rebase the branch — leaving stale
parent commits in the diff. This workflow automates the fix:

- Triggers on PR merge, finds child PRs stacked on the merged branch
- Rebases each child onto the merged PR's base using `git rebase --onto`
  to replay only the child's own commits
- Walks the full chain recursively to any depth (PR2 → PR3 → PR4...)
- On conflict: leaves a comment with manual fix instructions, stops chain
- Deletes the merged branch after rebasing (replaces GitHub auto-delete)
@sbalabanov
Copy link
Copy Markdown
Contributor

Bash in yaml is uncool. Better have the logic in supported language with tests. May be outside this repo.

@sbalabanov sbalabanov added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 1cf33fe Mar 9, 2026
11 checks passed
@github-actions github-actions Bot deleted the preetam/ci-rebase branch March 9, 2026 19:21
@behinddwalls
Copy link
Copy Markdown
Collaborator Author

Bash in yaml is uncool. Better have the logic in supported language with tests. May be outside this repo.

Yes.. I am hoping Github releases something soon so i can delete this...if not i can port it to go and release a binary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants