fix(ci): normalize release target_commitish for bump-back PR base#1616
Merged
Conversation
The Publish workflow's version-bump-back step passed the release's target_commitish straight into peter-evans/create-pull-request as `base`. When a release carries a fully-qualified target (refs/heads/master) rather than a bare branch name, the action tries to fetch into the currently checked-out branch and fails with 'refusing to fetch into branch ... checked out' (git exit 128), so the bump-back PR is never opened and master drifts from the published npm version. Resolve the target branch once, stripping any refs/heads/ prefix, and reuse it for both the checkout ref and the PR base. Signed-off-by: Lee Calcote <leecalcote@gmail.com>
Contributor
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
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
When
v0.21.19was released, the Publish Node.js Package workflow's "Open PR with package.json version bump" step failed with:The step is
continue-on-error: true, so the publish itself still succeeded — but the version-bump-back PR was never opened andmaster'spackage.jsondrifted from the version published to npm (it had to be opened manually as #1610).Root cause
The step passed
github.event.release.target_commitishstraight intopeter-evans/create-pull-requestasbase. That value can be either a bare branch name (master) or a fully-qualified ref (refs/heads/master), depending on how the release was created.create-pull-request'sbasemust be a short branch name; given a full ref it tries to fetch into the currently checked-out branch, which git refuses (exit 128).Fix
Resolve the target branch once in a new
Resolve target branchstep, stripping anyrefs/heads/prefix, and reuse the normalized value for both the checkoutrefand the bump-back PRbase.Testing
python3 -c "import yaml; yaml.safe_load(...)"— workflow parses.${VAR#prefix}strip:refs/heads/master→master, and a baremasteris unchanged.