Skip to content

fix(promote-release): gate promote on release-PR mergeability - #1133

Merged
c-vigo merged 2 commits into
devfrom
bugfix/1132-promote-validate-mergeability
Jul 15, 2026
Merged

c-vigo merged 2 commits into
devfrom
bugfix/1132-promote-validate-mergeability

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Summary

promote-release.yml's validate job verified the release PR was non-draft,
approved, and CI-green — but never checked whether it was actually mergeable.
Because the sequence is validate → promote (undraft, irreversible under immutable releases) → merge, a PR that was BEHIND main (or BLOCKED/DIRTY) passed
validation, the GitHub Release was published, and only then did the merge fail —
leaving a half-promoted release whose PR never reached main and which cannot
be re-run to recover.

Observed on vig-os/commit-action 0.3.0 promote (release branch 5 CI-only commits
behind main; main enforces "require branches up to date").

Change

In validate → Find and verify release PR, after the existing draft/approval/CI
checks, fetch mergeable + mergeStateStatus via gh pr view and fail fast
unless the PR is mergeable:

  • accept CLEAN / HAS_HOOKS / UNSTABLE (CI already asserted green separately)
  • reject BEHIND (with a "update the release branch" hint), BLOCKED, DIRTY
  • re-query while either field is UNKNOWN (GitHub computes mergeability async)

This keeps the invariant: never start the irreversible publish unless the merge
can succeed. Scope is the downstream scaffold template
(assets/workspace/.github/workflows/promote-release.yml); the primary fail-fast
validate gate the issue asked for.

The secondary considerations in the issue (TOCTOU between validate and merge;
gh pr merge --auto / branch-update in the merge step) are intentionally left
out of this minimal fix.

Tests

  • tests/test_promote_mergeability.py (new) pins that validate's PR check
    queries mergeable/mergeStateStatus, rejects BEHIND, and re-queries
    UNKNOWN. Added RED-first, then implemented.
  • actionlint (shellcheck on the embedded run script) and the full pre-commit
    suite are green.

Closes #1132

c-vigo added 2 commits July 15, 2026 18:09
validate verified the release PR was non-draft, approved, and CI-green
but never checked mergeability. Since promote (undraft, irreversible)
runs before merge, a BEHIND/BLOCKED/DIRTY PR passed validation, the
Release was published, then merge failed — a half-promoted release.

Fetch mergeable/mergeStateStatus in the validate PR check and fail fast
unless mergeable, re-querying while GitHub reports UNKNOWN.

Refs: #1132
@c-vigo
c-vigo merged commit 35c74d1 into dev Jul 15, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1132-promote-validate-mergeability branch July 15, 2026 16:21
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