Skip to content

Trigger auto-merge on approval, not just on CI completion - #348

Merged
dwoz merged 2 commits into
mainfrom
fix-auto-merge-approval-gap
Nov 19, 2026
Merged

dwoz merged 2 commits into
mainfrom
fix-auto-merge-approval-gap

Conversation

@dwoz

@dwoz dwoz commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes a gap in the automated-update release flow where CI-then-approval ordering left PRs sitting unmerged.

The existing .github/workflows/auto-merge.yml only fires on workflow_run of "Pull Request or Push" completing. When CI goes green before a human approves, the auto-merge job runs once, finds zero approving reviews, exits, and never re-fires — because a bare approval doesn't retrigger a workflow_run. The PR then stalls waiting on a manual merge.

Reproduced on PR #347 (Release 0.23.2) which had green CI for two days before approval; after approval it still had to be merged by hand.

Changes

  • Add a pull_request_review trigger (types: [submitted]) alongside the existing workflow_run.
  • Add a shared "resolve PR number + head SHA" step that works for either event (workflow_run.head_sha vs pull_request.head.sha).
  • In the merge step:
    • re-verify the automated-update label is still on the PR (defence in depth)
    • require at least one APPROVED review (unchanged)
    • new: require every statusCheckRollup entry to be COMPLETED with conclusion in {SUCCESS, SKIPPED, NEUTRAL}. The previous version got this from the workflow_run if guard, which is useless on the review-event path.
  • Merge stays --squash --delete-branch, App token acquisition unchanged.

Now either ordering unblocks automatically:

  • CI-then-approval: pull_request_review fires → CI already green → merges.
  • Approval-then-CI: pull_request_review fires → CI still running → script waits. Next workflow_run completion fires → approval already there → merges.

Test plan

  • Open a dummy automated-update-labelled PR, let CI finish, approve, confirm it merges without manual intervention.
  • Open another dummy PR, approve immediately (before CI completes), confirm it waits for CI and then auto-merges on the next workflow_run completion.
  • Open a dummy PR that fails CI, approve it, confirm the workflow exits 1 with a "failing check(s)" log and does not merge.

dwoz added 2 commits November 17, 2026 15:49
The prior revision only fired on ``workflow_run`` of "Pull Request or
Push" completing.  When CI went green before a human had approved, the
one chance to run the auto-merge step came and went with zero approvals
recorded, and the PR then sat open indefinitely -- the approval event
alone didn't re-trigger anything.  This bit us on PR #347 (Release
0.23.2) which had green CI for two days before approval; after approval
it still had to be merged by hand.

Add a ``pull_request_review`` trigger and a shared resolution step that
figures out the PR + head SHA regardless of which event fired.  The
merge step now:

* re-verifies the ``automated-update`` label on the PR
* requires at least one approving review (unchanged)
* requires every status check to be ``COMPLETED`` with conclusion in
  ``{SUCCESS, SKIPPED, NEUTRAL}`` -- the previous version relied on the
  ``workflow_run`` ``if`` guard for this, which doesn't help when the
  entry point is a review event

So either ordering now unblocks: CI-then-approval (workflow_run fires,
approval already in place) or approval-then-CI (pull_request_review
fires, waits for CI, next workflow_run completion then merges).

The merge is still ``--squash --delete-branch`` and the App token path
is unchanged.
ubuntu-latest rolled to 26.04 "resolute" in Nov 2026, which dropped the
bare ``libxml2`` runtime package from the archive.  Every pre-commit CI
run since then fails during ``apt-get install`` with::

    E: Package 'libxml2' has no installation candidate

breaking the pre-commit gate for every open PR.  ``libxml2-dev`` is
still in resolute and pulls the current ``libxml2``-ABI runtime SONAME
package in transitively, so dropping just the bare ``libxml2`` entry
from the install list is enough.  Rest of the package list is
unchanged.
@dwoz
dwoz merged commit 265462e into main Nov 19, 2026
89 checks passed
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