Skip to content

Commit 2cb747a

Browse files
committed
Pass workflow values via env in release workflows
Move the remaining expression values that were interpolated directly into run: scripts (inputs.tag, github.repository, step outputs, repository owner/name) into env: variables, matching the pattern already used elsewhere in these workflows and GitHub's script-injection guidance. Behavior is unchanged. Fixes #602
1 parent 70bdaf3 commit 2cb747a

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎.github/workflows/release-publish.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ jobs:
8484
env:
8585
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8686
CHANGELOG: ${{ steps.changelog.outputs.body }}
87+
REPO_OWNER: ${{ github.repository_owner }}
88+
REPO_NAME: ${{ github.event.repository.name }}
8789
run: |
8890
# Extract PR numbers from changelog links like [#123](...).
8991
# A changelog without matching links has no contributors to fetch.
@@ -92,7 +94,7 @@ jobs:
9294
CONTRIBUTORS=""
9395
if [ -n "$PR_NUMBERS" ]; then
9496
# Build a single GraphQL query to fetch all PR authors.
95-
QUERY='{ repository(owner: "${{ github.repository_owner }}", name: "${{ github.event.repository.name }}") {'
97+
QUERY="{ repository(owner: \"$REPO_OWNER\", name: \"$REPO_NAME\") {"
9698
while IFS= read -r PR; do
9799
[ -n "$PR" ] && QUERY="$QUERY pr$PR: pullRequest(number: $PR) { author { login } }"
98100
done <<< "$PR_NUMBERS"
@@ -110,9 +112,10 @@ jobs:
110112
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
111113
BODY: ${{ steps.changelog.outputs.body }}
112114
CONTRIBUTORS: ${{ steps.contributors.outputs.list }}
115+
PRERELEASE: ${{ steps.version.outputs.prerelease }}
113116
run: |
114117
PRERELEASE_FLAG=""
115-
if [[ "${{ steps.version.outputs.prerelease }}" == "true" ]]; then
118+
if [[ "$PRERELEASE" == "true" ]]; then
116119
PRERELEASE_FLAG="--prerelease"
117120
fi
118121

‎.github/workflows/release-wporg.yml‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ jobs:
3939

4040
- name: Resolve tag
4141
id: resolve
42+
env:
43+
INPUT_TAG: ${{ inputs.tag }}
4244
run: |
43-
TAG="${{ inputs.tag }}"
45+
TAG="$INPUT_TAG"
4446
# Ensure the tag has a "v" prefix.
4547
[[ "$TAG" == v* ]] || TAG="v$TAG"
4648
echo "tag=$TAG" >> $GITHUB_OUTPUT
@@ -50,16 +52,19 @@ jobs:
5052
env:
5153
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5254
TAG: ${{ steps.resolve.outputs.tag }}
55+
REPO: ${{ github.repository }}
5356
run: |
5457
gh release download "$TAG" \
55-
--repo "${{ github.repository }}" \
58+
--repo "$REPO" \
5659
--pattern "plugin-sqlite-database-integration.zip" \
5760
--dir .
5861
unzip plugin-sqlite-database-integration.zip
5962
6063
- name: Verify release metadata
64+
env:
65+
VERSION: ${{ steps.resolve.outputs.version }}
6166
run: |
62-
bash bin/verify-release-metadata.sh plugin-sqlite-database-integration "${{ steps.resolve.outputs.version }}"
67+
bash bin/verify-release-metadata.sh plugin-sqlite-database-integration "$VERSION"
6368
6469
- name: Deploy to WordPress.org
6570
uses: 10up/action-wordpress-plugin-deploy@2.3.0

0 commit comments

Comments
 (0)