Skip to content

gate: a workflow_run release evaluates the default branch tip, not the commit whose CI passed #1099

Backlog

Description

@goosewobbler

Problem

In a CI-gated immediate release (release.yml triggered by workflow_run on CI), the gate evaluates the wrong commit when main has moved on since the CI run started.

runGate (src/gate/gate.ts) takes the commit from getGitHubContext(), which reads process.env.GITHUB_SHA, and looks up its merged PR with listPullRequestsAssociatedWithCommit. In a workflow_run event, GITHUB_SHA is the latest commit on the default branch, not the commit whose CI run completed (github.event.workflow_run.head_sha). Runner GITHUB_* variables can't be overridden from workflow env, and the action has no input for the commit, so callers can't correct it.

Checking out workflow_run.head_sha before the gate step doesn't help: the gate then reads that commit's files but still evaluates the tip's PR labels.

Impact

Two PRs, A then B, merge before A's CI finishes:

  1. B can release before its own CI passes. A's CI completes first; the gate in that run evaluates the tip (B). If B carries release:immediate, it releases while B's CI is still running. The release itself also runs from the tip of the target branch.
  2. A's labels are never evaluated. Every gate run sees B, so a release:immediate on A is silently dropped. This happens whether A's CI run finishes or is cancelled, so it gets more likely in repos whose CI uses concurrency: cancel-in-progress on the default branch.

The standing-PR publish path isn't affected; it dispatches the release workflow directly.

Proposed fix

  • Resolve the gate's commit from the event: when GITHUB_EVENT_NAME is workflow_run, read workflow_run.head_sha from GITHUB_EVENT_PATH; otherwise use GITHUB_SHA. An explicit sha action input (passed through as INPUT_SHA) would also let callers override it.
  • Release from that commit, or refuse when the target branch has moved past it and report why in the summary, instead of releasing the tip. Releasing the verified commit is close to the 0.53.0 theme of publishing the plan the version step recorded; refusing is enough for this issue.

Repro

  1. A repo with ci.releaseStrategy: standing-pr and the documented workflow_run-gated release.yml.
  2. Merge PR A, then PR B (labelled release:immediate) before A's CI completes.
  3. A's CI finishes: the gate reports B's labels and releases B while B's CI is still running.

Seen in v0.47.1.

Activity

  1. added this to the 0.48.0 milestone on Nov 24, 2026
  2. added
    type:bug
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions