Skip to content

Commit 65e5888

Browse files
authored
Merge pull request Homebrew#196045 from Homebrew/template-injection
workflows: fix most `template-injection` warnings
2 parents 066c3dd + a5fbc6f commit 65e5888

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

.github/workflows/cache.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ jobs:
7777
- name: Get cache key
7878
id: cache-key
7979
run: |
80-
cache_key_prefix="${{ runner.os }}"
81-
if [ "${{ runner.os }}" = macOS ]
80+
cache_key_prefix="${RUNNER_OS}"
81+
if [ "${RUNNER_OS}" = macOS ]
8282
then
8383
macos_version="$(sw_vers -productVersion)"
8484
cache_key_prefix="${macos_version%%.*}-$(uname -m)"

.github/workflows/create-replacement-pr.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ jobs:
162162
HOMEBREW_GPG_PASSPHRASE: ${{ inputs.autosquash && secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
163163
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_CORE_PUBLIC_REPO_EMAIL_TOKEN }}
164164
MESSAGE: ${{ inputs.message }}
165+
AUTOSQUASH_FLAG: ${{ inputs.autosquash && '--autosquash' || '' }}
166+
CLEAN_FLAG: ${{ inputs.autosquash && '' || '--clean' }}
167+
NO_CHERRY_PICK_FLAG: ${{ inputs.autosquash && '' || '--no-cherry-pick' }}
165168
run: |
166169
# Don't quote arguments that might be empty; this causes errors.
167170
brew pr-pull \
@@ -172,8 +175,10 @@ jobs:
172175
--committer="$BREWTESTBOT_NAME_EMAIL" \
173176
--root-url="https://ghcr.io/v2/homebrew/core" \
174177
--retain-bottle-dir \
175-
${{ inputs.autosquash && '--autosquash' || '--clean --no-cherry-pick' }} \
176-
${{ inputs.message && '--message="$MESSAGE"' || '' }} \
178+
${AUTOSQUASH_FLAG:+"${AUTOSQUASH_FLAG}"} \
179+
${CLEAN_FLAG:+"--clean"} \
180+
${NO_CHERRY_PICK_FLAG:+"--no-cherry-pick"} \
181+
${MESSAGE:+"--message=${MESSAGE}"} \
177182
"$PR"
178183
179184
- name: Generate build provenance
@@ -191,14 +196,16 @@ jobs:
191196
HOMEBREW_GPG_PASSPHRASE: ${{ secrets.BREWTESTBOT_GPG_SIGNING_SUBKEY_PASSPHRASE }}
192197
HOMEBREW_GITHUB_PACKAGES_USER: brewtestbot
193198
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_CORE_GITHUB_PACKAGES_TOKEN}}
199+
WARN_ON_UPLOAD_FAILURE_FLAG: ${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}}
194200
run: |
195201
# Don't quote arguments that might be empty; this causes errors when `brew`
196202
# interprets them as empty arguments when we want `brew` to ignore them instead.
197203
brew pr-upload \
198204
--debug \
199205
--committer="$BREWTESTBOT_NAME_EMAIL" \
200206
--root-url="https://ghcr.io/v2/homebrew/core" \
201-
${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}}
207+
${WARN_ON_UPLOAD_FAILURE_FLAG:+"${WARN_ON_UPLOAD_FAILURE_FLAG}"}
208+
202209
203210
- name: Push commits
204211
uses: Homebrew/actions/git-try-push@master

.github/workflows/publish-commit-bottles.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
id: pr-branch-check
9292
env:
9393
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
94+
AUTOSQUASH: ${{inputs.autosquash}}
9495
run: |
9596
pr_data="$(
9697
gh api \
@@ -169,7 +170,7 @@ jobs:
169170
echo "remote=$remote"
170171
echo "node_id=$node_id"
171172
echo "requires_merge=$requires_merge"
172-
echo "replace=${{ inputs.autosquash }}"
173+
echo "replace=${AUTOSQUASH}"
173174
} >> "$GITHUB_OUTPUT"
174175
175176
if "$pushable" && [[ "$fork_type" != "Organization" ]] ||
@@ -195,12 +196,14 @@ jobs:
195196
fromJson(steps.pr-branch-check.outputs.requires_merge)
196197
env:
197198
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
199+
AUTOSQUASH: ${{inputs.autosquash}}
200+
UPLOAD: ${{!inputs.autosquash}}
198201
run: |
199202
gh workflow run create-replacement-pr.yml \
200203
--ref "$GITHUB_REF_NAME" \
201204
--field pull_request="$PR" \
202-
--field autosquash=${{ inputs.autosquash }} \
203-
--field upload=${{ !inputs.autosquash }} \
205+
--field autosquash="${AUTOSQUASH}" \
206+
--field upload="${UPLOAD}" \
204207
--field warn_on_upload_failure=false \
205208
--field message="$INPUT_MESSAGE" \
206209
--repo "$GITHUB_REPOSITORY"
@@ -299,6 +302,8 @@ jobs:
299302
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_CORE_PUBLIC_REPO_EMAIL_TOKEN}}
300303
EXPECTED_SHA: ${{needs.check.outputs.head_sha}}
301304
LARGE_RUNNER: ${{inputs.large_runner}}
305+
WARN_ON_UPLOAD_FAILURE_FLAG: ${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}}
306+
MESSAGE: ${{inputs.message}}
302307
run: |
303308
local_git_head="$(git rev-parse HEAD)"
304309
remote_git_head="$(git ls-remote origin "pull/$PR/head" | cut -f1)"
@@ -330,8 +335,8 @@ jobs:
330335
--committer="$BREWTESTBOT_NAME_EMAIL" \
331336
--root-url="https://ghcr.io/v2/homebrew/core" \
332337
--retain-bottle-dir \
333-
${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}} \
334-
${{inputs.message && '--message="$INPUT_MESSAGE"' || ''}} \
338+
${WARN_ON_UPLOAD_FAILURE_FLAG:+"${WARN_ON_UPLOAD_FAILURE_FLAG}"} \
339+
${MESSAGE:+"--message=${MESSAGE}"} \
335340
"$PR"
336341
337342
- name: Generate build provenance
@@ -348,14 +353,16 @@ jobs:
348353
HOMEBREW_GITHUB_PACKAGES_USER: brewtestbot
349354
HOMEBREW_GITHUB_PACKAGES_TOKEN: ${{secrets.HOMEBREW_CORE_GITHUB_PACKAGES_TOKEN}}
350355
REPO_PATH: ${{steps.set-up-homebrew.outputs.repository-path}}
356+
WARN_ON_UPLOAD_FAILURE_FLAG: ${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}}
351357
run: |
352358
# Don't quote arguments that might be empty; this causes errors when `brew`
353359
# interprets them as empty arguments when we want `brew` to ignore them instead.
354360
brew pr-upload \
355361
--debug \
356362
--committer="$BREWTESTBOT_NAME_EMAIL" \
357363
--root-url="https://ghcr.io/v2/homebrew/core" \
358-
${{inputs.warn_on_upload_failure && '--warn-on-upload-failure' || ''}}
364+
${WARN_ON_UPLOAD_FAILURE_FLAG:+"${WARN_ON_UPLOAD_FAILURE_FLAG}"}
365+
359366
360367
echo "head_sha=$(git -C "$REPO_PATH" rev-parse HEAD)" >> "$GITHUB_OUTPUT"
361368

.github/workflows/tests.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,13 @@ jobs:
374374
runs-on: ubuntu-latest
375375
steps:
376376
- name: Check `tests` result
377+
env:
378+
TESTS_RESULT: ${{ needs.tests.result }}
379+
DEPS_TESTS_RESULT: ${{ needs.test_deps.result }}
380+
RUNNERS_PRESENT: ${{ needs.setup_runners.outputs.runners_present }}
381+
SYNTAX_ONLY: ${{ needs.setup_tests.outputs.syntax-only }}
377382
run: |
378-
result='${{ needs.tests.result }}'
383+
result="${TESTS_RESULT}"
379384
# Silence lint error about backtick usage inside single quotes.
380385
# shellcheck disable=SC2016
381386
printf '::notice ::`tests` job status: %s\n' "$result"
@@ -388,7 +393,7 @@ jobs:
388393
# shellcheck disable=SC2016
389394
printf '::error ::`tests` job %s.\n' "$result"
390395
391-
deps_result='${{ needs.test_deps.result }}'
396+
deps_result="${DEPS_TESTS_RESULT}"
392397
if [[ "$deps_result" = "skipped" ]]
393398
then
394399
# Silence lint error about backtick usage inside single quotes.
@@ -399,8 +404,8 @@ jobs:
399404
exit 1
400405
fi
401406
402-
runners_present='${{ needs.setup_runners.outputs.runners_present }}'
403-
syntax_only='${{ needs.setup_tests.outputs.syntax-only }}'
407+
runners_present="${RUNNERS_PRESENT-}"
408+
syntax_only="${SYNTAX_ONLY-}"
404409
405410
# The tests job can be skipped only if the PR is syntax-only
406411
# or no runners were assigned.

0 commit comments

Comments
 (0)