Repository navigation
fix(ci): hand over the release PR when Actions may not create PRs - #150
Merged
Merged
Conversation
The first run of the two-stage Release workflow (v2.1.0, run 40541920352) bumped the versions, pushed release/v2.1.0 and then failed red at "Open release PR": GitHub Actions is not permitted to create or approve pull requests. The repository setting behind it is off and there is no RELEASE_TOKEN secret, so the step fell back to GITHUB_TOKEN and was refused outright. The header comment, the notice and CONTRIBUTING.md all assumed GITHUB_TOKEN could open the PR and would only fail to start CI. When `gh pr create` fails, the branch is already pushed, so the step now exits 0 with a warning and writes the error, the compare link, the PR body and a ready `gh pr create` command to the step summary. When the error is the Actions permission, the summary also names the two permanent fixes (RELEASE_TOKEN or the repository setting). The success path is unchanged. The release workflow test extracts the step's script from the YAML and runs it against a stub gh, covering the success, existing-PR, refused and other-failure paths. The header comment and the CONTRIBUTING callout now describe the three states. Closes #144 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.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.
Description
The first run of the two-stage Release workflow (v2.1.0, run 40541920352) bumped the three version files, wrote the changelog, pushed
release/v2.1.0and then failed red at Open release PR:The repository setting behind it (Settings > Actions > General > Workflow permissions > "Allow GitHub Actions to create and approve pull requests") is off and there is no
RELEASE_TOKENsecret, so the step fell back toGITHUB_TOKEN, which cannot open a pull request at all in that state. The workflow header, the step's notice and the CONTRIBUTING.md callout all assumedGITHUB_TOKENcould open the PR and would only fail to start CI, so "close and reopen" was advice for a PR that never existed. #143 was opened by hand from the pushed branch.This is option 3 from the issue, which applies whichever permanent fix is chosen:
release.yml, "Open release PR" step. Whengh pr createfails, the branch is already pushed, so the step exits 0 with a::warning::and writes to the step summary: the error verbatim, the compare link with the title prefilled, and a ready-to-pastegh pr create … --body-file - <<'PR_BODY'command carrying the PR body the workflow would have used (RELEASE_NOTES.mdis gitignored, so the summary is the only copy of it). When the error is the Actions permission, the summary also names both permanent fixes. The success and existing-PR paths are unchanged apart from writing the body underRUNNER_TEMP.RELEASE_TOKENpresent (PR opened as that user, CI runs by itself),GITHUB_TOKENwith the setting on (PR opens, close and reopen once for CI),GITHUB_TOKENwith the setting off (hand-off through the step summary).scripts/__tests__/release-workflow.test.jsnow extracts the step'srun: |script from the YAML and executes it against a stubgh: success, an existing PR refreshed rather than duplicated, the CI notice only withoutRELEASE_TOKEN, refusal by the Actions permission (exit 0, warning, compare link, command, body, both fixes named), and any other failure (same hand-off, no permission advice). It also asserts the script takes every input fromenv:and never from a${{ }}expression.Step summary as written when the PR is refused (stub run)
Release PR not opened
Branch
release/v2.2.0is pushed, butgh pr createfailed:The step ran with
GITHUB_TOKENand the repository setting Allow GitHub Actions to create and approve pull requests (Settings > Actions > General > Workflow permissions) is off. To let the workflow open the PR itself next time, either add aRELEASE_TOKENrepository secret (fine-grained PAT with Contents and Pull requests: write; the PR is then opened as that user and CI starts on its own) or turn that setting on (the PR then still needs one close and reopen before CI runs).Open the PR by hand from the compare view, pasting the body below, or with the GitHub CLI:
Not done here, both need the repository owner: a fine-grained PAT stored as
RELEASE_TOKEN(the better option: the PR is opened as that user and CI runs on it by itself), or turning the setting on. For an organization-owned repository the setting is inherited from the organization, and reading the PMDevSolutions value needs theadmin:orgscope that theghlogin on this machine lacks, so it may have to be enabled there first:After that the workflow opens the PR itself, but it still needs one close and reopen before CI starts.
Related Issue
Closes #144. Refs #139, #143.
Type of Change
Checklist
pnpm vitest run --config scripts/__tests__/vitest.config.js scripts/__tests__/)./scripts/lint-and-format.sh --check)pnpm tsc --noEmit): not applicable, no TypeScript changedCONTRIBUTING.md, therelease.ymlheader)🤖 Generated with Claude Code