fix: authenticate hotfix finalize state write with the state token#207
Merged
Conversation
Signed-off-by: Joshua Temple <joshua.temple@stablekernel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The generated hotfix
finalizejob writes manifest state to the trunk branch via the Contents REST API authenticated with bareGITHUB_TOKEN(github-actions[bot]). On a repo with a require-pull-request rule on trunk, that write is rejected:The promote and orchestrate finalize state writes already authenticate with the configurable state token (an admin PAT set to bypass the rule via
enforce_admins=false), which is why those suites are green. The hotfix finalize was the one remaining trunk-write still on the bot token.Audit
Every hotfix job inspected for trunk/PR-touching credentials:
cascade hotfix plan(read-only)gh pr create+ label seed + clean mergegh pr mergecascade parse-config(read-only)cascade hotfix finalizeContents API write to trunkGITHUB_TOKEN(bot, blocked)No remaining bare-
GITHUB_TOKENon any trunk- or PR-touching hotfix operation. The finalize step's separateGITHUB_TOKEN(release/tag API, not gated by branch protection) is intentionally left as the default, mirroring the promote finalize structure.Fix
internal/generate/hotfix.gofinalize job:GH_TOKENnow usesgetStateTokenRef()(the same accessor used by apply, merge, promote, and orchestrate), defaulting toGITHUB_TOKENwhen no state token is configured for back-compat.Verification
GH_TOKENis the configured state token, and falls back toGITHUB_TOKENwhen unset.go build ./...,go test ./...(1414 passed),golangci-lint run ./...(clean). e2e module builds and vets clean.