ci: read the release branch name from env instead of interpolating it - #5603
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Hardens the finalize-release GitHub Actions workflow by preventing unsafe shell interpolation of the merged PR’s head ref when deriving release metadata and deleting the release branch.
Changes:
- Pass
github.event.pull_request.head.refviaenv(HEAD_REF) for “Extract release info from branch name”. - Pass
github.event.pull_request.head.refviaenv(HEAD_REF) for “Delete release branch”.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
tig
approved these changes
Jul 29, 2026
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.
Hi, and thanks for Terminal.Gui.
.github/workflows/finalize-release.ymlreads the merged PR's branch name into a shell variable in two steps:BRANCH="${{ github.event.pull_request.head.ref }}"once in "Extract release info from branch name" and again in "Delete release branch".
Actions substitutes
${{ ... }}into the script text before bash runs, so the branch name becomes part of the script instead of a value assigned toBRANCH. Git allows$,(,)and backticks in branch names, and$(...)still runs inside double quotes.The guard rails already here matter, and I would rather note them than overstate this:
github.event.pull_request.merged == true, so a maintainer has to merge the PR first;startsWith(github.event.pull_request.head.ref, 'release/'), so the name has to begin withrelease/— but everything after that prefix is unconstrained;GITHUB_TOKENstays read-only regardless of thecontents: writerequest.So the realistic shape is a branch like
release/v1.0.0$(...)executing on the runner once someone merges it, in a job that goes on to create tags and releases. Hardening rather than a live exploit.The change binds the value to
env:in both steps and leaves the rest untouched:The
${BRANCH#release/}and${TAG#v}stripping downstream is unchanged, so tag and semver extraction behave exactly as before.Disclosure: I used AI assistance to help spot this and prepare the change, and I checked the workflow, its trigger and its conditions myself.