Skip to content

ci: auto-enable merge-when-ready on every PR open - #240

Merged
getappz merged 3 commits into
masterfrom
ci/auto-merge-on-open
Jul 18, 2026
Merged

ci: auto-enable merge-when-ready on every PR open#240
getappz merged 3 commits into
masterfrom
ci/auto-merge-on-open

Conversation

@getappz

@getappz getappz commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • New .github/workflows/auto-merge.yml: on every non-draft PR's opened/reopened/ready_for_review event, calls gh pr merge --auto --squash --delete-branch on it — flips the PR into GitHub's native auto-merge state
  • Answers the recurring BEHIND-status friction this session hit on feat(ci): wire LOC-gate into pre-commit hook (staged files only) #237/ci: add PR title Conventional Commits check #238/chore: add CODEOWNERS #239: branch protection's required_status_checks.strict=true means every PR goes BEHIND whenever a sibling merges first, and a human/agent has to remember to pass --auto (or manually rebase) to unstick it. This makes that automatic — no one has to remember anything
  • Branch protection's required checks (build x3, cargo audit, clippy, fmt) still fully gate the actual merge; this workflow doesn't bypass or weaken that, it only removes the manual step of asking for auto-merge
  • Configurable without a code change: gh variable set AUTO_MERGE_ENABLED --body false disables it repo-wide; unset or true (default) keeps it on
  • Plain pull_request trigger (not pull_request_target) — no checkout, no need for elevated fork-PR permissions, avoids the zizmor pull_request_target-is-almost-always-insecure flag hit on ci: add PR title Conventional Commits check #238 earlier this session

Test plan

  • Minimal pull-requests: write permission only, matching this repo's per-job permissions convention
  • Will self-verify: this PR is itself non-draft, so its own new workflow (evaluated from this branch's content) should enable auto-merge on itself once opened

Summary by CodeRabbit

  • Chores
    • Added automated pull request merging for eligible, non-draft pull requests.
    • Pull requests are squash-merged automatically when enabled, with their source branches deleted afterward.

No human or agent needs to remember gh pr merge --auto anymore --
this flips every non-draft PR into GitHub's native auto-merge state
the moment it's opened. Branch protection's required status checks
still gate the actual merge; GitHub re-syncs a BEHIND branch itself.

Configurable without a code change: gh variable set AUTO_MERGE_ENABLED
--body false to disable repo-wide.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@getappz, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 2 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ef221149-cba4-4168-9967-7a1941fd98cd

📥 Commits

Reviewing files that changed from the base of the PR and between de042bd and b7d00dc.

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

Walkthrough

Adds a GitHub Actions workflow that automatically enables squash auto-merge for eligible non-draft pull requests unless disabled by the AUTO_MERGE_ENABLED repository variable.

Changes

Automatic pull request merging

Layer / File(s) Summary
Auto-merge workflow execution
.github/workflows/auto-merge.yml
The workflow listens for selected pull request events, skips drafts or explicitly disabled runs, and invokes authenticated squash auto-merge with branch deletion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PullRequest
  participant GitHubActions
  participant GitHubMergeAPI
  PullRequest->>GitHubActions: Open, reopen, or mark ready for review
  GitHubActions->>GitHubActions: Check repository setting and draft status
  GitHubActions->>GitHubMergeAPI: Request squash auto-merge
  GitHubMergeAPI->>PullRequest: Merge after required checks and delete branch
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the new auto-merge-on-PR-open workflow and matches the main change.
Description check ✅ Passed The description covers the summary and basic test plan, though it omits the reviewers section and the repository's full checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/auto-merge-on-open

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

enablePullRequestAutoMerge rejects the Actions-issued token with
'Resource not accessible by integration' regardless of declared
permissions. Needs a real PAT in the AUTOMERGE_TOKEN secret.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
.github/workflows/auto-merge.yml (1)

10-17: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider adding a concurrency group to cancel duplicate runs.

If multiple trigger events fire for the same PR in quick succession (e.g., opened then ready_for_review), duplicate workflow runs could overlap. A concurrency group keyed on the PR number would cancel superseded runs and reduce noise.

♻️ Optional: add concurrency group
 jobs:
   enable-auto-merge:
     name: Enable auto-merge
+    concurrency:
+      group: auto-merge-${{ github.event.pull_request.number }}
+      cancel-in-progress: true
     # Toggle repo-wide without touching this file:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/auto-merge.yml around lines 10 - 17, Add a workflow-level
or job-level concurrency configuration for enable-auto-merge, using the pull
request number as the group key and enabling cancellation of in-progress runs.
Keep the existing auto-merge condition and runner configuration unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/auto-merge.yml:
- Around line 10-17: Add a workflow-level or job-level concurrency configuration
for enable-auto-merge, using the pull request number as the group key and
enabling cancellation of in-progress runs. Keep the existing auto-merge
condition and runner configuration unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d626d14-0371-47af-a1e5-3efbe3e49dda

📥 Commits

Reviewing files that changed from the base of the PR and between bfcf67a and de042bd.

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

External contributions never get auto-merge auto-enabled here
regardless of CI status -- head.repo.full_name != repository is an
explicit gate, not an accident of GitHub blocking secrets from
fork-triggered pull_request runs.
@getappz
getappz merged commit ef1338a into master Jul 18, 2026
17 checks passed
@getappz
getappz deleted the ci/auto-merge-on-open branch July 18, 2026 04:46
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.

1 participant