Skip to content

Conversation

@ANcpLua
Copy link
Owner

@ANcpLua ANcpLua commented Jan 15, 2026

Summary

Adds the advanced auto-merge workflow from ancplua-claude-plugins:

  • ✅ Auto-approve + auto-merge patch/minor Dependabot updates
  • ⚠️ Comments on major updates requiring manual review
  • ✅ Renovate bot support
  • ✅ AI agent PRs (Copilot, Jules, Claude branches)
  • ✅ CodeRabbit approval auto-merge

Test plan

  • Verify workflow triggers on Dependabot PR
  • Confirm major version updates get comment instead of auto-merge

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added automated GitHub Actions workflow to streamline PR approvals and merging for dependency updates and automated contributions.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings January 15, 2026 06:06
@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@coderabbitai
Copy link

coderabbitai bot commented Jan 15, 2026

Warning

Rate limit exceeded

@ANcpLua has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6ba17f4 and eac10d2.

📒 Files selected for processing (1)
  • .github/workflows/auto-merge.yml

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

A new GitHub Actions workflow is introduced that automates PR merging and approvals for four distinct sources: Dependabot, Renovate, AI agents (copilot/julius/claude branch prefixes), and CodeRabbit reviews. Each source has conditional job logic using GitHub CLI commands for approving and merging PRs.

Changes

Cohort / File(s) Change Summary
GitHub Actions Auto-merge Workflow
.github/workflows/auto-merge.yml
New file (+136 lines). Defines four conditional jobs triggered on PR events and review submissions. Includes Dependabot patch/minor auto-merge logic (major updates get PR comments), Renovate auto-approval and merge, AI agent detection and auto-merge, and CodeRabbit review-based auto-merge with squash strategy. Uses GitHub CLI for PR operations and includes permission scopes for repository and pull-request management.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding an auto-merge workflow with protection for major version updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an automated merge workflow that handles pull requests from various trusted sources including Dependabot, Renovate, AI agents, and CodeRabbit. The workflow aims to streamline the merge process for low-risk updates while requiring manual review for potentially breaking changes.

Changes:

  • Adds auto-merge workflow with support for Dependabot (with major version protection), Renovate, AI agent branches, and CodeRabbit approvals
  • Implements automatic approval and squash merging for trusted PRs
  • Adds special handling to comment on major version updates requiring manual review

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

types: [completed]

permissions:
contents: write
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The workflow has broad permissions (contents: write, pull-requests: write) that apply to all jobs. Following the principle of least privilege, jobs should only have the permissions they actually need. For example, the CodeRabbit job only needs to enable auto-merge (pull-requests: write) but not contents: write. Consider setting permissions at the job level instead of the workflow level to minimize the security surface area.

Suggested change
contents: write
contents: read

Copilot uses AI. Check for mistakes.
Comment on lines 90 to 92
startsWith(github.event.pull_request.head.ref, 'copilot/') ||
startsWith(github.event.pull_request.head.ref, 'jules/') ||
startsWith(github.event.pull_request.head.ref, 'claude/')
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The AI agent job condition checks github.event.pull_request.head.ref but this may be null or undefined for some event types (like check_suite). This could cause the job to fail or be skipped unexpectedly. Consider adding a null check or ensuring that the job only runs for event types where pull_request data is guaranteed to be available.

Suggested change
startsWith(github.event.pull_request.head.ref, 'copilot/') ||
startsWith(github.event.pull_request.head.ref, 'jules/') ||
startsWith(github.event.pull_request.head.ref, 'claude/')
github.event.pull_request != null &&
(
startsWith(github.event.pull_request.head.ref, 'copilot/') ||
startsWith(github.event.pull_request.head.ref, 'jules/') ||
startsWith(github.event.pull_request.head.ref, 'claude/')
)

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +7
# 2. AI Agent fix PRs (copilot/, jules/, claude/): Auto-merge when CI passes
# 3. CodeRabbit approved PRs: Auto-merge when CI passes
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comments claim "Auto-merge when CI passes" for tiers 2 and 3, but the workflow does not actually wait for or verify that CI checks have passed before enabling auto-merge. The workflow should either include logic to verify CI status or update the comments to accurately reflect the actual behavior (immediate auto-merge without CI verification).

Suggested change
# 2. AI Agent fix PRs (copilot/, jules/, claude/): Auto-merge when CI passes
# 3. CodeRabbit approved PRs: Auto-merge when CI passes
# 2. AI Agent fix PRs (copilot/, jules/, claude/): Auto-merge
# 3. CodeRabbit approved PRs: Auto-merge

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +85
- name: Auto-approve Renovate PRs
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve "$PR_URL"

- name: Enable auto-merge for Renovate
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"

Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The Renovate auto-merge job approves and merges all Renovate PRs without checking for major version updates, unlike the Dependabot job which has special handling for major updates (lines 50-66). This inconsistency means major breaking changes from Renovate could be auto-merged without manual review. Consider adding similar major version protection for Renovate PRs or documenting why this difference in behavior is intentional.

Suggested change
- name: Auto-approve Renovate PRs
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve "$PR_URL"
- name: Enable auto-merge for Renovate
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"
- name: Detect Renovate major updates
id: renovate_metadata
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Detect if this Renovate PR represents a major version update.
# Renovate typically labels such PRs with "major" or "renovate/major".
LABELS_JSON=$(gh pr view "$PR_URL" --json labels)
if echo "$LABELS_JSON" | grep -qi '"name":"major"'; then
echo "update-type=version-update:semver-major" >> "$GITHUB_OUTPUT"
elif echo "$LABELS_JSON" | grep -qi '"name":"renovate/major"'; then
echo "update-type=version-update:semver-major" >> "$GITHUB_OUTPUT"
else
echo "update-type=version-update:semver-non-major" >> "$GITHUB_OUTPUT"
fi
- name: Auto-approve Renovate PRs
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve "$PR_URL"
- name: Enable auto-merge for Renovate (non-major)
if: steps.renovate_metadata.outputs.update-type != 'version-update:semver-major'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"
- name: Comment on Renovate major updates
if: steps.renovate_metadata.outputs.update-type == 'version-update:semver-major'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment "$PR_URL" --body "## ⚠️ Renovate Major Version Update
This is a **major version update** created by Renovate and may contain breaking changes.
**Auto-merge has been disabled. Manual review and merge are required.**"

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +13
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Using pull_request_target with automatic approval and merging poses a security risk. The pull_request_target event runs with write permissions in the context of the base repository, even for PRs from forks. While the current implementation restricts execution to specific actors (dependabot, renovate, specific branch prefixes), a compromised bot account or malicious actor could potentially exploit this. Consider adding additional safety checks such as verifying that the PR is from the same repository (not a fork) or requiring CI checks to pass before auto-merging.

Copilot uses AI. Check for mistakes.
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The gh CLI commands do not have error handling or continue-on-error configured. If a command fails (e.g., due to permissions issues, API rate limits, or network problems), the workflow will fail silently without providing useful feedback. Consider adding error handling or at least ensuring that failures are visible and don't leave PRs in an inconsistent state where they might be partially approved but not merged.

Suggested change
run: gh pr merge --auto --squash "$PR_URL"
run: gh pr merge --auto --squash "$PR_URL" || { echo "Failed to auto-merge CodeRabbit-approved PR $PR_URL"; exit 1; }

Copilot uses AI. Check for mistakes.
Comment on lines 86 to 121
ai-agent-auto-merge:
name: AI Agent auto-merge
runs-on: ubuntu-latest
if: |
startsWith(github.event.pull_request.head.ref, 'copilot/') ||
startsWith(github.event.pull_request.head.ref, 'jules/') ||
startsWith(github.event.pull_request.head.ref, 'claude/')

steps:
- name: Identify AI agent
id: agent
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
if [[ "$BRANCH" == copilot/* ]]; then
echo "agent=Copilot" >> "$GITHUB_OUTPUT"
elif [[ "$BRANCH" == jules/* ]]; then
echo "agent=Jules" >> "$GITHUB_OUTPUT"
elif [[ "$BRANCH" == claude/* ]]; then
echo "agent=Claude" >> "$GITHUB_OUTPUT"
fi

- name: Auto-approve AI agent PRs
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AGENT: ${{ steps.agent.outputs.agent }}
run: |
echo "Auto-approving $AGENT PR"
gh pr review --approve "$PR_URL" --body "✅ Auto-approved: $AGENT autonomous fix PR"

- name: Enable auto-merge for AI agent PRs
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The AI agent auto-merge job auto-approves and auto-merges PRs based solely on branch name prefixes (copilot/, jules/, claude/). This is risky because any user with write access to the repository could create a branch with these prefixes and have their changes automatically merged without proper review. Consider adding additional validation such as checking the PR author or requiring that these branches come from specific bot accounts only.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +48
dependabot-auto-merge:
name: Dependabot auto-merge
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'

steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Auto-approve patch and minor updates
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr review --approve "$PR_URL"

- name: Enable auto-merge for patch and minor
if: steps.metadata.outputs.update-type != 'version-update:semver-major'
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "$PR_URL"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The Dependabot auto-merge job will run on every event type listed in the trigger (opened, synchronize, reopened, ready_for_review, pull_request_review submitted, and check_suite completed), even though it only needs to run when the PR is first opened or updated. This could lead to unnecessary workflow executions. Consider adding event type filtering to the job's if condition to only run on relevant events, such as checking that github.event_name is 'pull_request_target'.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +66
gh pr comment "$PR_URL" --body "## ⚠️ Major Version Update

This is a **major version update** that may contain breaking changes.

**Manual review required.**

Dependency: \`$DEP_NAMES\`
Update: \`$PREV_VERSION\` → \`$NEW_VERSION\`"
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The multi-line comment body contains indented text that will be included in the comment as-is, potentially with unwanted leading whitespace on each line. This could result in poorly formatted GitHub comments. Consider using a heredoc or adjusting the indentation to ensure the comment text starts at column 0 after the opening quote.

Suggested change
gh pr comment "$PR_URL" --body "## ⚠️ Major Version Update
This is a **major version update** that may contain breaking changes.
**Manual review required.**
Dependency: \`$DEP_NAMES\`
Update: \`$PREV_VERSION\` → \`$NEW_VERSION\`"
gh pr comment "$PR_URL" --body-file - <<EOF
## ⚠️ Major Version Update
This is a **major version update** that may contain breaking changes.
**Manual review required.**
Dependency: \`$DEP_NAMES\`
Update: \`$PREV_VERSION\` → \`$NEW_VERSION\`
EOF

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 17
check_suite:
types: [completed]
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The workflow is triggered by the check_suite event (line 16-17), but all jobs reference github.event.pull_request which may not be available in check_suite event payloads. The check_suite event has a different structure and may not include pull_request information directly, which could cause these jobs to fail or behave unexpectedly when triggered by check_suite completion. Consider either removing the check_suite trigger or adding logic to handle the different event payload structures appropriately.

Suggested change
check_suite:
types: [completed]

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.github/workflows/auto-merge.yml:
- Around line 86-92: The ai-agent-auto-merge job currently trusts branch
prefixes via the if condition (startsWith(github.event.pull_request.head.ref,
'copilot/') || ...), which allows any collaborator to create such branches;
update the job's if conditional on ai-agent-auto-merge to also validate
github.actor for each prefix (mirror the pattern used by
Dependabot/Renovate/CodeRabbit) so the condition requires both the actor equals
the trusted bot account and the branch prefix matches; verify and use the actual
bot usernames for Copilot/Jules/Claude in the github.actor checks before
committing.
🧹 Nitpick comments (1)
.github/workflows/auto-merge.yml (1)

68-84: Consider adding major version protection for Renovate PRs.

Unlike the Dependabot job which requires manual review for major updates, Renovate PRs are auto-merged regardless of version bump type. This inconsistency could lead to unexpected breaking changes being auto-merged.

If Renovate is configured to only create patch/minor PRs, this is acceptable. Otherwise, consider using Renovate's labels or commit message conventions to detect major updates and apply similar protection.

Is Renovate configured to exclude major version updates, or is this intentional behavior?

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between c0fe75f and 6ba17f4.

📒 Files selected for processing (1)
  • .github/workflows/auto-merge.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Agent
🔇 Additional comments (4)
.github/workflows/auto-merge.yml (4)

1-9: LGTM!

Clear documentation of the tiered auto-merge strategy with well-defined categories for each automation tier.


24-67: LGTM!

The Dependabot job implements a solid pattern:

  • Patch/minor updates are auto-approved and auto-merged with squash.
  • Major updates receive a detailed comment and require manual review.
  • Using dependabot/fetch-metadata@v2 provides reliable semver classification.

94-121: LGTM for the implementation logic.

The agent identification and approval steps are well-implemented with proper output handling and audit trail via approval body message.


123-136: LGTM!

The CodeRabbit job correctly:

  • Triggers only on pull_request_review events with approved state from coderabbitai[bot]
  • Enables auto-merge without adding another approval (relying on branch protection rules)
  • Uses squash merge consistently with other jobs

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

… validation

- Remove unused check_suite trigger (no job references it)
- Add actor validation to AI agent job for security (prevents anyone from creating copilot/jules/claude branches)
@ANcpLua ANcpLua merged commit fce4798 into main Jan 15, 2026
2 checks passed
@ANcpLua ANcpLua deleted the ci/add-auto-merge branch January 15, 2026 07:33
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