Skip to content

feat(auto-rebase): add workflow to rebase behind Dependabot PRs - #206

Draft
caugner wants to merge 1 commit into
mainfrom
auto-rebase-dependabot-prs
Draft

caugner wants to merge 1 commit into
mainfrom
auto-rebase-dependabot-prs

Conversation

@caugner

@caugner caugner commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Description

Add an auto-rebase reusable workflow, and call it from this repo on pushes to main. It comments @dependabot rebase on the oldest open Dependabot PR that is behind its base branch and has auto-merge enabled.

  • Skips PRs with commits not authored by Dependabot.
  • Skips PRs with a rebase request newer than the last push.
  • Retries while GitHub still reports the merge state as UNKNOWN.

Motivation

Ensure Dependabot PRs can auto-merge in repositories that require branches to be up to date. Dependabot does not rebase PRs that are only behind, so they stay blocked after another PR merges.

Additional details

  • Only one PR is rebased per run, to avoid O(N²) CI runs. Each merge to main triggers the next rebase.
  • The "behind" state is detected through mergeStateStatus == BEHIND, which GitHub reports only when up-to-date branches are required, so no per-repo configuration is needed.

Related issues and pull requests

Comment `@dependabot rebase` on the oldest open Dependabot PR that has
auto-merge enabled and is `BEHIND` its base branch. Runs on push to
`main`, because Dependabot does not rebase PRs that are only behind.

- Rebase one PR per run, so each merge to `main` triggers the next.
- Skip PRs with commits not authored by Dependabot, and PRs with a
  rebase request newer than the last push.
- Skip PRs that are blocked, as rebasing would not unblock them.
- Wait while GitHub still reports `UNKNOWN` merge state for auto-merge
  PRs, and warn about those still unknown after the last attempt.
- The reusable workflow needs no `GITHUB_TOKEN` permissions, since every
  request uses the caller's PAT.
- Document that pushes made with `GITHUB_TOKEN` do not trigger the
  workflow.
@caugner
caugner force-pushed the auto-rebase-dependabot-prs branch from a5cd367 to 8a1c938 Compare October 22, 2026 15:14
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