-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add auto-merge workflow with major version protection #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,137 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Auto-merge workflow for trusted PRs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Tiers: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 1a. Dependabot PRs: Auto-approve + auto-merge for patch/minor | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 1b. Renovate PRs: Auto-approve + auto-merge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 2. AI Agent fix PRs (copilot/, jules/, claude/): Auto-merge when CI passes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # 3. CodeRabbit approved PRs: Auto-merge when CI passes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Auto-merge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull_request_target: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types: [opened, synchronize, reopened, ready_for_review] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+13
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull_request_review: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types: [submitted] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write | |
| contents: read |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
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
AI
Jan 15, 2026
There was a problem hiding this comment.
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.
| 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
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Renovate and AI agent auto-merge jobs do not check if the pull request is in draft state before enabling auto-merge. This could result in draft PRs being automatically merged, which is likely unintended. Consider adding a condition to check that the PR is not a draft, similar to checking if the PR event type is 'ready_for_review' or by adding a condition like 'github.event.pull_request.draft == false'.
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
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.
| - 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
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CodeRabbit auto-merge job does not check if the pull request is in draft state before enabling auto-merge. This could result in draft PRs being automatically merged after CodeRabbit approval, which is likely unintended. Consider adding a condition to check that the PR is not a draft by adding 'github.event.pull_request.draft == false' to the job's if condition.
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
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.
| 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; } |
There was a problem hiding this comment.
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).