Skip to content

ci(release): refuse a Promote RC dispatch from any ref but main - #5181

Open
Marian Koreniuk (themoriarti) wants to merge 1 commit into
cozystack:mainfrom
themoriarti:fix/promote-rc-dispatch-ref
Open

Marian Koreniuk (themoriarti) wants to merge 1 commit into
cozystack:mainfrom
themoriarti:fix/promote-rc-dispatch-ref

Conversation

@themoriarti

@themoriarti Marian Koreniuk (themoriarti) commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Adds a first step to the parse job of promote-rc.yaml that fails when github.ref is not refs/heads/main, before anything is written. This is A20 in #3278.

A workflow_dispatch runs the copy of the workflow at the dispatched ref. On 2026-10-16 a dispatch from release-1.6 ran that branch's older copy (one job instead of five, https://github.com/cozystack/cozystack/actions/runs/38882938797) and was re-run from main. Since #4861 the release assets are signed, and the same dispatch would now fail at the upload step, after the staging branch, the promotion-* candidate and the draft release already exist. docs/release.md also pins the signature identity to this workflow on main, so a dispatch from another ref should stop at the front door.

The step follows the shape of Validate dispatch branch in cut-prerelease.yaml: one shell comparison, an ::error:: that names main, exit 1.

Test

hack/promote-rc-dispatch-ref_test.bats extracts the step's run with yq and executes it under dash for refs/heads/main (passes), a release branch, a tag and an empty ref (each fails and names main), and pins the step to be parse's first step reading github.ref. It runs with the rest of hack/*_test.bats via make bats-unit-tests. zizmor on the workflow reports no findings.

Docs

One clause in step 3 of the regular release sequence in docs/release.md. #5169 edits the same file further down and the promote job of the same workflow; the hunks do not overlap.

Checklist

  • Commit is signed off with --signoff
  • Commit carries exactly one Assisted-by: LLM trailer
  • hack/check-commit-trailers.sh upstream/main..HEAD passes
  • bats hack/promote-rc-dispatch-ref_test.bats and bats hack/bats-strict-setup.bats pass

Summary by CodeRabbit

  • Bug Fixes
    • Release candidate promotion now rejects requests made from anything other than the main branch, preventing promotion steps from running for other branches, tags, or empty refs.
  • Documentation
    • Updated release instructions to clarify the branch restriction.
  • Tests
    • Added checks confirming valid main-branch requests pass and other refs are rejected.

A workflow_dispatch runs the copy of promote-rc.yaml at the ref it was
dispatched from. On 2026-10-16 a dispatch from release-1.6 ran that
branch's older copy, one job instead of five, and had to be re-run from
main. Since the release assets are signed, the same dispatch would now
fail at the upload step, after the staging branch, the promotion-*
candidate and the draft release already exist, and docs/release.md pins
the signature identity to this workflow on main.

Make the first step of parse compare github.ref with refs/heads/main and
fail with an error that names main, so a dispatch from a release branch,
a tag or a SHA stops before the first write. The bats test runs the
step's shell under dash for main, a release branch, a tag and an empty
ref, and pins the step to be the first one in parse.

Assisted-by: LLM
Signed-off-by: Marian Koreniuk <[email protected]>
@github-actions github-actions Bot added area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) size/M This PR changes 30-99 lines, ignoring generated files labels Nov 2, 2026
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d32092a and aebef09.

Files selected for processing: 3
  • .github/workflows/promote-rc.yaml
  • docs/release.md
  • hack/promote-rc-dispatch-ref_test.bats

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

The promotion workflow now rejects dispatches unless the ref is refs/heads/main. Tests cover accepted and rejected refs, and the release instructions describe the guard.

Changes: Release promotion ref guard

Layer / File(s) Summary
Add and verify the dispatch ref guard
.github/workflows/promote-rc.yaml, hack/promote-rc-dispatch-ref_test.bats, docs/release.md
The parse job checks that the dispatch ref is refs/heads/main before later steps. Bats tests cover the guard’s position and behavior for main, a release branch, a tag, and an empty ref. The release instructions document the check.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: kind/bug, area/ci, area/release, size/S

Suggested reviewers: lexfrei

Merge Risk: Minimal · up to aebef

The change adds a useful check that makes promotion dispatches from non-main refs fail early on current workflow copies. Older release branches or tags that still hold a pre-guard copy are not protected. This was already true before the PR. Nothing here should block merging.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: blocking Promote RC dispatches from refs other than main.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (2 skipped: 2 unsupported.)

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) size/M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant