Skip to content

ci(auto-merge): skip draft PRs + redundant approvals - #205

Draft
caugner wants to merge 3 commits into
mainfrom
skip-auto-merge-for-draft-prs
Draft

caugner wants to merge 3 commits into
mainfrom
skip-auto-merge-for-draft-prs

Conversation

@caugner

@caugner caugner commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Description

Update the auto-merge workflow to skip draft PRs and PRs whose latest commit is already approved.

  • Skip the job for draft PRs, and re-run on ready_for_review so eligible PRs are approved and merged once marked ready.
  • Re-check the draft state right before gh pr merge --auto.
  • Skip the approval if the token's user has already approved the latest commit.

Motivation

Prevent gh pr merge --auto from failing on draft PRs, and avoid approving the same commit repeatedly on re-runs.

Additional details

The draft state is re-checked before merging because github.event.pull_request.draft is a snapshot from when the event fired. A PR converted to draft while the job is running would otherwise still fail.

Approvals on older commits are ignored, so repos that require approval of the most recent push still get re-approved.

Caller workflows in other repos need types: [opened, synchronize, reopened, ready_for_review] on pull_request_target to benefit from the re-run on ready_for_review.

Related issues and pull requests

Related to mdn/browser-compat-data#30934 (failing run: https://github.com/mdn/browser-compat-data/actions/runs/39590369100/job/119189517084).

Skip the `auto-merge` job for draft PRs and re-run on `ready_for_review`, so eligible PRs are approved and merged once marked ready. Re-check the draft state before `gh pr merge --auto`, since the event payload can be stale.

`gh pr merge --auto` fails on draft PRs.
Skip the approval when the token's user has already approved the PR's head commit. Approvals on older commits are ignored, so repos that require approval of the most recent push are re-approved.

Re-runs (e.g. on `ready_for_review`) would otherwise approve repeatedly.
Avoid splicing the shell variable into the jq program.
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