Skip to content

feat: add dependabot-rebase workflow#125

Merged
don-petry merged 1 commit into
mainfrom
feat/add-dependabot-rebase-workflow
Apr 6, 2026
Merged

feat: add dependabot-rebase workflow#125
don-petry merged 1 commit into
mainfrom
feat/add-dependabot-rebase-workflow

Conversation

@don-petry

@don-petry don-petry commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds dependabot-rebase.yml workflow that triggers on push to main and comments @dependabot rebase on behind Dependabot PRs
  • Unblocks the auto-merge serialization issue caused by strict: true branch protection

Test plan

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added automated GitHub Actions workflow to manage Dependabot pull requests. The workflow automatically detects when dependency updates fall behind the main branch and requests rebasing to keep them synchronized.

Triggers on push to main and comments @dependabot rebase on any
Dependabot PRs that have fallen behind, unblocking auto-merge when
strict status checks are enabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 6, 2026 02:11
@coderabbitai

coderabbitai Bot commented Apr 6, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 93c4433b-f902-4b3b-b6d5-ea3eafab62f6

📥 Commits

Reviewing files that changed from the base of the PR and between 0e60dbc and b711717.

📒 Files selected for processing (1)
  • .github/workflows/dependabot-rebase.yml

📝 Walkthrough

Walkthrough

Added a GitHub Actions workflow that automatically triggers Dependabot to rebase pull requests when they fall behind the main branch. The workflow generates a GitHub App token, identifies open Dependabot PRs, calculates how far behind each is, and posts a rebase command for those needing updates.

Changes

Cohort / File(s) Summary
Dependabot Rebase Workflow
.github/workflows/dependabot-rebase.yml
New workflow triggered on push to main that generates a GitHub App token, queries open Dependabot pull requests, checks how many commits each is behind using the GitHub API, and comments @dependabot rebase on those that need rebasing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-dependabot-rebase-workflow

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud

sonarqubecloud Bot commented Apr 6, 2026

Copy link
Copy Markdown

@don-petry don-petry merged commit d6e7072 into main Apr 6, 2026
14 of 15 checks passed
@don-petry don-petry deleted the feat/add-dependabot-rebase-workflow branch April 6, 2026 02:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automation to keep Dependabot PRs up-to-date after merges to main, helping unblock auto-merge when branch protection requires strict up-to-date checks.

Changes:

  • Introduces a new GitHub Actions workflow that runs on pushes to main.
  • Uses a GitHub App token to detect open Dependabot PRs that are behind and posts @dependabot rebase to trigger rebases.

fi

while IFS=' ' read -r PR_NUMBER HEAD_REF; do
BEHIND=$(gh api "repos/$REPO/compare/main...$HEAD_REF" \

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HEAD_REF can contain slashes for Dependabot branches (e.g. dependabot/github_actions/...). In the compare API call, the head ref is part of the URL path, so unescaped / will break the request and leave BEHIND empty (causing the step to fail or skip rebases). URL-encode HEAD_REF (or switch to an API/GraphQL lookup that doesn’t require embedding the ref in the path) before calling repos/$REPO/compare/....

Suggested change
BEHIND=$(gh api "repos/$REPO/compare/main...$HEAD_REF" \
ENCODED_HEAD_REF=$(python3 -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1], safe=""))' "$HEAD_REF")
BEHIND=$(gh api "repos/$REPO/compare/main...$ENCODED_HEAD_REF" \

Copilot uses AI. Check for mistakes.
Comment on lines +67 to +69
echo "PR #$PR_NUMBER ($HEAD_REF) is $BEHIND commit(s) behind — requesting rebase"
gh pr comment "$PR_NUMBER" --repo "$REPO" \
--body "@dependabot rebase"

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will add a new @dependabot rebase comment on every push to main while a PR remains behind, which can spam PR timelines. Consider making the operation idempotent (e.g., edit the last bot comment instead of creating a new one, or check for an existing recent @dependabot rebase comment before posting).

Suggested change
echo "PR #$PR_NUMBER ($HEAD_REF) is $BEHIND commit(s) behind — requesting rebase"
gh pr comment "$PR_NUMBER" --repo "$REPO" \
--body "@dependabot rebase"
EXISTING_REBASE_COMMENT=$(gh api "repos/$REPO/issues/$PR_NUMBER/comments?per_page=100" \
--jq 'map(select(.body == "@dependabot rebase")) | length')
if [[ "$EXISTING_REBASE_COMMENT" -gt 0 ]]; then
echo "PR #$PR_NUMBER ($HEAD_REF) is $BEHIND commit(s) behind — rebase already requested"
else
echo "PR #$PR_NUMBER ($HEAD_REF) is $BEHIND commit(s) behind — requesting rebase"
gh pr comment "$PR_NUMBER" --repo "$REPO" \
--body "@dependabot rebase"
fi

Copilot uses AI. Check for mistakes.
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