Skip to content

feat(automerge): scheduled sweep for stale auto-merge queue#162

Open
JacobPEvans wants to merge 3 commits intomainfrom
fix/automerge-sweep
Open

feat(automerge): scheduled sweep for stale auto-merge queue#162
JacobPEvans wants to merge 3 commits intomainfrom
fix/automerge-sweep

Conversation

@JacobPEvans
Copy link
Copy Markdown
Owner

@JacobPEvans JacobPEvans commented Apr 12, 2026

PR #162 Metadata Update

Summary

  • Adds automerge-sweep.yml — a 70-line cron workflow that runs every 10 minutes
  • Finds open PRs from trusted bots (renovate, dependabot, jacobpevans-github-actions) where
    auto-merge is enabled + mergeStateStatus == CLEAN but GitHub hasn't executed the merge
  • Toggles auto-merge off/on to force GitHub to re-evaluate (proven fix for RC3 stale queue
    bug)
  • Uses the same GitHub App token as release-please for consistent identity
  • Replaces the unmerged feat/automerge-reliability branch (500+ lines, 3 scripts) with
    minimal code

Context

GitHub's native auto-merge queue sometimes goes stale — a PR has all checks green,
auto-merge enabled, and mergeStateStatus=CLEAN, but the merge never executes. The only
known fix is toggling auto-merge off/on. The existing inline retry in _release-please.yml
handles initial creation, but nothing catches the stale queue after that. PRs were sitting
for 1-2 hours before eventual manual intervention.

Changes

  1. feat(automerge): Initial scheduled sweep implementation — cron workflow to detect and
    poke stale auto-merge queue every 10 minutes
  2. fix(automerge): Address Copilot review feedback — refined concurrency control,
    permissions scoping, result limits, regex patterns, merge method handling, and error
    surfacing

Test Plan

  • Manual toggle on ansible-proxmox-apps#177 — merged instantly after poke
  • Manual toggle on nix-ai#492 — checks re-running, will merge on completion
  • Run gh workflow run automerge-sweep.yml after merge to verify cron works
  • Observe next release-please or renovate PR merges within 10 min without intervention

Related

🤖 Generated with Claude Code

GitHub's auto-merge sometimes goes stale: PR is CLEAN with auto-merge
enabled but the merge never executes. Toggling auto-merge off/on forces
re-evaluation and the merge completes within seconds.

This replaces the unmerged 500-line healer (feat/automerge-reliability)
with a 70-line workflow that runs every 10 minutes across all repos.

(claude)
Copilot AI review requested due to automatic review settings April 12, 2026 13:43
@gemini-code-assist
Copy link
Copy Markdown

Note

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

Copy link
Copy Markdown
Contributor

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

Adds an organization-level scheduled GitHub Actions workflow to periodically “poke” PRs that appear merge-ready with auto-merge enabled but are stuck in GitHub’s stale auto-merge queue, by toggling auto-merge off/on using a GitHub App token.

Changes:

  • Introduces a new automerge-sweep cron workflow running every 10 minutes.
  • Enumerates open PRs in a fixed list of repos and filters to trusted bot PRs with autoMergeRequest != null and mergeStateStatus == CLEAN.
  • Disables and re-enables auto-merge via gh pr merge to force GitHub to re-evaluate the queue.

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

Comment thread .github/workflows/automerge-sweep.yml
Comment thread .github/workflows/automerge-sweep.yml Outdated
Comment thread .github/workflows/automerge-sweep.yml Outdated
Comment thread .github/workflows/automerge-sweep.yml Outdated
Comment thread .github/workflows/automerge-sweep.yml Outdated
Comment thread .github/workflows/automerge-sweep.yml Outdated
…mit, regex, merge method, error surfacing

- Add workflow-level concurrency group (cancel-in-progress) to prevent overlapping sweeps
- Set job permissions: {} — GITHUB_TOKEN is unused; App token carries its own permissions
- Add --limit 1000 to gh pr list to avoid missing stuck PRs in busy repos
- Tighten author regex to exact [bot] suffix + $ anchor (prevents false prefix matches)
- Read autoMergeRequest.mergeMethod and pass appropriate flag instead of hard-coding --squash
- Replace || true with ::warning:: annotations so failures surface in Actions logs
…equests needed

gh pr merge and gh pr list require pull-requests:write only; contents:write
was unused and violates least-privilege.
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