Skip to content

Commit b4f896d

Browse files
authored
Fix GHA variable interpolation (#199)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed <!-- Describe what has changed in this PR --> Don't use GHA var interpolation directly. ## Why? <!-- Tell your future self why have you made these changes --> It's a command Injection vulnerability. (reported by Security) ## Checklist <!--- add/delete as needed ---> 1. Closes SDK-4256 2. How was this tested: <!--- Please describe how you tested your changes/how we can test them --> 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io -->
1 parent 78efa8e commit b4f896d

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

.github/workflows/docker-images.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ jobs:
5151
fetch-depth: 0
5252

5353
- name: Lint dockerfile
54-
run: docker run --rm -i hadolint/hadolint hadolint --ignore DL3029 - < dockerfiles/${{inputs.lang}}.Dockerfile
54+
env:
55+
LANG: ${{ inputs.lang }}
56+
run: docker run --rm -i hadolint/hadolint hadolint --ignore DL3029 - < "dockerfiles/$LANG.Dockerfile"
5557

5658
- uses: actions/setup-go@v4
5759
if: ${{ !inputs.do-push || github.event.pull_request.head.repo.fork }}
@@ -64,13 +66,18 @@ jobs:
6466

6567
- name: Build and save image for artifacts
6668
if: ${{ !inputs.do-push || github.event.pull_request.head.repo.fork }}
69+
env:
70+
LANG: ${{ inputs.lang }}
71+
SDK_VERSION: ${{ inputs.sdk-version || 'checked-out-sdk/' }}
72+
IMAGE_TAG_ARGS: ${{ inputs.sdk-repo-ref && format('--image-tag {0}-{1}', inputs.lang, inputs.docker-tag-ext) || ''}}
73+
TAG_LATEST_ARGS: ${{ inputs.as-latest && '--tag-as-latest' || ''}}
6774
run: |
68-
go run ./cmd build-worker-image --language ${{ inputs.lang }} \
69-
--version ${{ inputs.sdk-version || 'checked-out-sdk/' }} \
75+
go run ./cmd build-worker-image --language "$LANG" \
76+
--version "$SDK_VERSION" \
7077
--save-image /tmp/image.tar \
7178
--platform linux/amd64 \
72-
${{ inputs.sdk-repo-ref && format('--image-tag {0}-{1}', inputs.lang, inputs.docker-tag-ext) || ''}} \
73-
${{ inputs.as-latest && '--tag-as-latest' || ''}}
79+
$IMAGE_TAG_ARGS \
80+
$TAG_LATEST_ARGS
7481
7582
- name: Prepare docker artifact
7683
if: ${{ !inputs.do-push || github.event.pull_request.head.repo.fork }}
@@ -124,14 +131,21 @@ jobs:
124131
password: ${{ secrets.DOCKER_PAT }}
125132

126133
- name: Build and push to Docker Hub
134+
env:
135+
LANG: ${{ inputs.lang }}
136+
SDK_VERSION: ${{ inputs.sdk-version || 'checked-out-sdk/' }}
137+
IMAGE_TAG_ARGS: ${{ inputs.sdk-repo-ref && format('--image-tag {0}-{1}', inputs.lang, inputs.docker-tag-ext) || ''}}
138+
TAG_LATEST_ARGS: ${{ inputs.as-latest && '--tag-as-latest' || ''}}
127139
run: |
128-
go run ./cmd build-push-worker-image --language ${{ inputs.lang }} \
129-
--version ${{ inputs.sdk-version || 'checked-out-sdk/' }} \
140+
go run ./cmd build-push-worker-image --language "$LANG" \
141+
--version "$SDK_VERSION" \
130142
--platform linux/amd64,linux/arm64 \
131143
--repo-prefix temporaliotest \
132-
${{ inputs.sdk-repo-ref && format('--image-tag {0}-{1}', inputs.lang, inputs.docker-tag-ext) || ''}} \
133-
${{ inputs.as-latest && '--tag-as-latest' || ''}}
144+
$IMAGE_TAG_ARGS \
145+
$TAG_LATEST_ARGS
134146
135147
- name: 🐳 Docker Hub image tag
148+
env:
149+
LANG: ${{ inputs.lang }}
136150
run: |
137-
echo "::notice title=🐳 Docker Hub image published for ${{ inputs.lang }}::Check temporaliotest/omes tags"
151+
echo "::notice title=🐳 Docker Hub image published for $LANG::Check temporaliotest/omes tags"

0 commit comments

Comments
 (0)