Skip to content

Commit 5ce6f10

Browse files
authored
Replace interpolated variables (#1834)
## What was changed Set a different variable to the interpolated inputs, and enclose them in quotes. ## Why? This is to prevent bash injections in our runners. ## Checklist How was this tested: Ran this workflow on my fork and read the logs, I did get 403ed at the "Create release" step.
1 parent ca0bdf3 commit 5ce6f10

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

.github/workflows/prepare-release.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ on:
2424
description: 'Publish Java Artifacts'
2525
required: true
2626
default: 'true'
27-
27+
env:
28+
INPUT_REF: ${{ github.event.inputs.ref }}
29+
INPUT_TAG: ${{ github.event.inputs.tag }}
30+
2831
jobs:
2932
create_draft_release:
3033
name: Create Github draft release
@@ -37,7 +40,7 @@ jobs:
3740
id: check_release
3841
run: |
3942
echo "::echo::on"
40-
gh release view --repo '${{ github.repository }}' '${{ github.event.inputs.tag }}' \
43+
gh release view --repo "$GITHUB_REPOSITORY" "$INPUT_TAG" \
4144
&& echo "::set-output name=already_exists::true" \
4245
|| echo "::set-output name=already_exists::false"
4346
env:
@@ -47,18 +50,18 @@ jobs:
4750
if: steps.check_release.outputs.already_exists == 'false'
4851
uses: actions/checkout@v3
4952
with:
50-
ref: '${{ github.event.inputs.ref }}'
53+
ref: ${{ env.INPUT_REF }}
5154

5255
- name: Create release
5356
if: steps.check_release.outputs.already_exists == 'false'
5457
run: >
5558
gh release create
56-
'${{ github.event.inputs.tag }}'
59+
"$INPUT_REF"
5760
--draft
58-
--repo '${{ github.repository }}'
59-
--title '${{ github.event.inputs.tag }}'
60-
--target '${{ github.event.inputs.ref }}'
61-
--notes-file 'releases/${{ github.event.inputs.tag }}'
61+
--repo "$GITHUB_REPOSITORY"
62+
--title "$INPUT_TAG"
63+
--target "$INPUT_REF"
64+
--notes-file releases/"$INPUT_TAG"
6265
env:
6366
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6467

@@ -71,7 +74,7 @@ jobs:
7174
- name: Checkout repo
7275
uses: actions/checkout@v3
7376
with:
74-
ref: '${{ github.event.inputs.ref }}'
77+
ref: ${{ env.INPUT_REF }}
7578

7679
# Our custom gradle version sniffing builds the maven release artifact
7780
# names out of the git tag ... but the repo isn't tagged (yet) so add a
@@ -80,7 +83,7 @@ jobs:
8083
# inspected and verified, the manual act of publishing the draft GH
8184
# release creates the tag.
8285
- name: Temporary tag
83-
run: git tag '${{ github.event.inputs.tag }}'
86+
run: git tag "$INPUT_TAG"
8487

8588
- name: Set up Java
8689
uses: actions/setup-java@v3
@@ -138,12 +141,12 @@ jobs:
138141
- name: Checkout repo
139142
uses: actions/checkout@v3
140143
with:
141-
ref: '${{ github.event.inputs.ref }}'
144+
ref: ${{ env.INPUT_REF }}
142145

143146
# See comment on temporary tag above. tldr: this is a local tag; never
144147
# gets pushed
145148
- name: Temporary tag
146-
run: git tag '${{ github.event.inputs.tag }}'
149+
run: git tag "$INPUT_TAG"
147150

148151
- name: Set up Java
149152
uses: actions/setup-java@v3
@@ -186,7 +189,7 @@ jobs:
186189
# the root directory of the contents of the archive.
187190
- name: Rename dirs
188191
run: |
189-
version="$(sed 's/^v//'<<<'${{ github.event.inputs.tag }}')"
192+
version="$(sed 's/^v//'<<<"$INPUT_TAG")"
190193
for dir in *; do mv "$dir" "temporal-test-server_${version}_${dir}"; done
191194
192195
- name: Tar (linux, macOS)
@@ -207,7 +210,7 @@ jobs:
207210

208211
- name: Upload
209212
run: |
210-
until gh release upload --clobber --repo ${{ github.repository }} ${{ github.event.inputs.tag }} *.zip *.tar.gz; do
213+
until gh release upload --clobber --repo $GITHUB_REPOSITORY "$INPUT_TAG" *.zip *.tar.gz; do
211214
echo "Attempt $((++attempts)) to upload release artifacts failed. Will retry in 20s"
212215
sleep 20
213216
done

0 commit comments

Comments
 (0)