Skip to content

Pass workflow values via env in release workflows - #604

Merged
JanJakes merged 2 commits into
WordPress:trunkfrom
0xABCD01:fix/release-workflows-env-vars
Nov 27, 2026
Merged

JanJakes merged 2 commits into
WordPress:trunkfrom
0xABCD01:fix/release-workflows-env-vars

Conversation

@0xABCD01

@0xABCD01 0xABCD01 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #602.

Pass expression values to run: scripts through env: variables instead of interpolating ${{ ... }} expressions directly into the shell script, following GitHub's script-injection guidance and the pattern already used elsewhere in these workflows (BRANCH, VERSION, CHANGELOG, …).

Changes, all behavior-preserving (same values, same commands):

release-wporg.yml:

  • "Resolve tag": inputs.tag via INPUT_TAG env var.
  • "Download plugin zip from release": github.repository via REPO env var.
  • "Verify release metadata": steps.resolve.outputs.version via VERSION env var.

release-publish.yml:

  • "Get contributors from changelog PRs": github.repository_owner / github.event.repository.name via REPO_OWNER / REPO_NAME env vars used in the GraphQL query string.
  • "Create GitHub release": steps.version.outputs.prerelease via PRERELEASE env var.

Notes

This is defense-in-depth hardening: today these workflows are only reachable by maintainers (merged release/* pull requests, manual dispatch), so nothing is exploitable as-is. Moving the values to env: removes the substitution-before-parsing footgun if inputs, branch naming, or triggers ever change.

Both files remain valid YAML and the modified shell snippets pass bash -n; the GraphQL query construction produces the identical string as before.

Summary by CodeRabbit

  • Chores
    • Updated release publishing to use consistent repository details and prerelease status across release steps.
    • These behind-the-scenes changes do not alter app features or the content presented in releases. Release creation and publishing remain focused on the same user-facing experience, with no new functionality or changes to how the app works.

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The release workflows now pass repository values and prerelease status to shell commands through environment variables instead of embedding GitHub expressions in scripts.

Changes: Release workflow input handling

Layer / File(s) Summary
Pass expression values through environment variables
.github/workflows/release-publish.yml, .github/workflows/release-wporg.yml
The contributor query passes repository owner and name as variables to gh api. The release step checks the PRERELEASE environment variable. The release download command uses GITHUB_REPOSITORY for its repository argument.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: janjakes

Merge Risk: Minimal · up to 826d5

This change hardens release workflow scripts by passing values through environment variables and gh api variables instead of interpolating expressions. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Pass workflow values via env in release workflows" matches the main change. The PR moves GitHub expression values in release-wporg.yml and release-publish.yml into step env: variables (INPU…
Linked Issues check Passed Issue #602 lists five direct expression interpolations. At the reviewed head, none remains in a run script:
- release-wporg.yml, "Resolve tag": TAG: ${{ inputs.tag }} is in env and the script uses `…
Out of Scope Changes check Passed The whole-PR diff from the merge base changes two files. release-wporg.yml has one line changed: github.repository becomes $GITHUB_REPOSITORY. release-publish.yml changes the contributor GraphQL q…
Full details: Title check

Explanation

The title "Pass workflow values via env in release workflows" matches the main change. The PR moves GitHub expression values in release-wporg.yml and release-publish.yml into step env: variables (INPUT_TAG, REPO, VERSION, REPO_OWNER, REPO_NAME, PRERELEASE) instead of interpolating them directly into run: scripts. The title is specific and concise, and a teammate scanning history would understand the primary change.

Full details: Linked Issues check

Explanation

Issue #602 lists five direct expression interpolations. At the reviewed head, none remains in a run script:

  • release-wporg.yml, "Resolve tag": TAG: ${{ inputs.tag }} is in env and the script uses $TAG. This was already present at the merge base. The PR does not change it, contrary to the PR description.
  • release-wporg.yml, "Download plugin zip from release": the PR changes --repo "${{ github.repository }}" to --repo "$GITHUB_REPOSITORY". This uses the default GitHub environment variable, not a step env: entry. The value is the same, so the requirement is met, though the mechanism differs from the issue's suggested step env: pattern.
  • release-wporg.yml, "Verify release metadata": VERSION: ${{ steps.resolve.outputs.version }} is in env and the script uses "$VERSION". This was already present at the merge base. The PR does not change it, contrary to the PR description.
  • release-publish.yml, "Get contributors from changelog PRs": the PR adds REPO_OWNER and REPO_NAME through gh api variables (-F owner='{owner}' -F name='{repo}') and a GraphQL query with $owner and $name variables. The PR description says the query string is identical to the previous one. It is not byte-identical: the query gains a newline and a variable declaration. The GraphQL semantics match. The gh {owner}/{repo} placeholders resolve from the repository context, not from the REPO_OWNER/REPO_NAME env entries named in the PR description. This is a mechanism difference; the values match for this repository. Uninterpolated query text is not an interpolation.
  • release-publish.yml, "Create GitHub release": PRERELEASE: ${{ steps.version.outputs.prerelease }} is added to env, and the test becomes [[ "$PRERELEASE" == "true" ]].
    No automated tests cover these workflow steps. The bash -n and YAML checks are author-reported and were not run here.
Full details: Out of Scope Changes check

Explanation

The whole-PR diff from the merge base changes two files. release-wporg.yml has one line changed: github.repository becomes $GITHUB_REPOSITORY. release-publish.yml changes the contributor GraphQL query construction and adds env entries (REPO_OWNER, REPO_NAME, PRERELEASE) with the matching script references. Each hunk replaces an expression named in #602 or supports that replacement. No triggers, permissions, other steps, or other commands change. The PR description claims changes to "Resolve tag" and "Verify release metadata" that the diff does not contain. This does not add out-of-scope changes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5a6d6e2e-afc3-452c-a1c1-457bd74e54c9
Commits

Reviewing files that changed from the base of the PR and between 92288b7 and 826d5f4.

Files selected for processing: 1

  • .github/workflows/release-publish.yml

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Use GITHUB_REPOSITORY for release downloads. Pass the repository owner, name, and prerelease flag to the publish scripts through step environment variables.

Fixes WordPress#602
@JanJakes
JanJakes force-pushed the fix/release-workflows-env-vars branch from 2cb747a to 92288b7 Compare November 27, 2026 14:36
Let GitHub CLI read the owner and name from the checked-out repository and pass them as query variables. This removes the two step environment variables and the escaped quotes in the query.

@JanJakes JanJakes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I rebased this onto trunk after #641 and updated the contributor lookup to use GraphQL variables. Looks good to me.

@JanJakes
JanJakes merged commit 758da32 into WordPress:trunk Nov 27, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release workflows: pass expression values via env instead of interpolating them into run scripts

2 participants