Skip to content

Commit ac37d80

Browse files
committed
ci: harden release tag resolution against shell injection
1 parent 2a7e258 commit ac37d80

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,19 @@ jobs:
2828
steps:
2929
- name: Determine tag to release
3030
id: tag
31+
env:
32+
INPUT_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || '' }}
33+
DISPATCH_TAG: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.tag || '' }}
34+
REF_NAME: ${{ github.ref_name }}
3135
run: |
32-
if [ -n "${{ github.event.inputs.tag }}" ]; then
33-
TAG="${{ github.event.inputs.tag }}"
34-
elif [ -n "${{ github.event.client_payload.tag }}" ]; then
35-
TAG="${{ github.event.client_payload.tag }}"
36+
if [ -n "${INPUT_TAG}" ]; then
37+
TAG="${INPUT_TAG}"
38+
elif [ -n "${DISPATCH_TAG}" ]; then
39+
TAG="${DISPATCH_TAG}"
3640
else
37-
TAG="${{ github.ref_name }}"
41+
TAG="${REF_NAME}"
3842
fi
39-
echo "tag=$TAG" >> $GITHUB_OUTPUT
43+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
4044
echo "Releasing tag: $TAG"
4145
4246
- name: Ensure CI succeeded for tag commit

0 commit comments

Comments
 (0)