fix: author hotfix resolution PR with trigger-capable state token#205
Merged
Conversation
The hotfix apply job opened the resolution PR with gh pr create under the job-level GH_TOKEN, which defaulted to GITHUB_TOKEN. A PR authored by github-actions[bot] does not fire on: pull_request workflows, so on a protected env branch the required status check could only post via on: workflow_run after the hotfix run finished. The apply job would not finish until the PR merged, the PR could not merge until the check posted, and the check could not post until the apply job finished: a deadlock. Set the apply job's job-level GH_TOKEN to the configured state token so the resolution PR is authored by a trigger-capable actor. on: pull_request then fires and the env-branch required check posts on PR open, independent of the apply job, while the poll-until-mergeable merge step still gates the merge on that check. When no state token is configured the token degrades to GITHUB_TOKEN; post-hotfix automation then requires a configured state_token, consistent with the merge step. 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
On a protected env branch requiring a status check, the generated hotfix flow deadlocks. The apply job opens the resolution PR with
gh pr createunder the job-levelGH_TOKEN, which defaulted toGITHUB_TOKEN. A PR authored by github-actions[bot] does not fireon: pull_requestworkflows, so the env-branch required check could only post viaon: workflow_runafter the hotfix run finished. The apply job does not finish until the PR merges, the PR cannot merge until the check posts, and the check cannot post until the apply job finishes.Fix
Set the apply job's job-level
GH_TOKENto the configured state token (config.GetStateToken()) so the resolution PR is authored by a trigger-capable actor.on: pull_requestthen fires and the required check posts on PR open, independent of the apply job. The existing poll-until-mergeable merge step still gates the merge on that check, so it remains genuinely gating. When no state token is configured the token degrades toGITHUB_TOKEN; post-hotfix automation then requires a configuredstate_token, consistent with the merge step's existing caveat.internal/generate/hotfix.go: apply-job envGH_TOKEN: ${{ secrets.GITHUB_TOKEN }}->GH_TOKEN: <getStateTokenRef()>. The clean-path merge step keeps its own state-token env unchanged.Verification
internal/generate/hotfix_test.goassert the apply job authors the PR under the state token (state-token configured) and degrades toGITHUB_TOKENotherwise. Red before, green after.go build ./...,go test ./...(1403 tests),golangci-lint run ./...all green. e2e module builds and vets clean. The bot-PR trigger suppression is a real-GitHub behavior the local harness cannot reproduce, so coverage rests on the generator assertion plus the live fleet re-run.