Skip to content

Commit 1d9409e

Browse files
google-adminbenknutson-googlemhucka
authored
Refactor Github Action per b/485167538 (#1201)
This is a http://go/LSC run by http://go/ghss to automatically refactor your Github Actions per http://b/485167538. This is a PR to help you upgrade to the latest standards in Github Actions. Please merge this PR to accept the changes. NOTE: if you do not accept this PR, it may be force merged by the GHSS team. See http://b/485167538 for more details. --------- Co-authored-by: Ben Knutson <benknutson@google.com> Co-authored-by: Michael Hucka <mhucka@google.com>
1 parent 45f97fc commit 1d9409e

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

.github/workflows/ci.yaml

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,25 @@ jobs:
126126
name: Use the user-provided SHA as the basis for comparison
127127
env:
128128
GH_TOKEN: ${{github.token}}
129+
INPUTS_SHA: ${{inputs.sha}}
129130
run: |
130131
set -x +e
131-
url="repos/${{github.repository}}/commits/${{inputs.sha}}"
132-
if full_sha="$(gh api $url -q '.sha')"; then
132+
url="repos/${{github.repository}}/commits/${INPUTS_SHA}"
133+
if full_sha="$(gh api "$url" -q '.sha')"; then
133134
echo "base=$full_sha" >> "$GITHUB_ENV"
134135
else
135136
{
136137
echo "### :x: Workflow error"
137138
echo "The SHA provided to _Run Workflow_ does not exist:"
138-
echo "<code>${{inputs.sha}}</code>"
139+
echo "<code>${INPUTS_SHA}</code>"
139140
} >> "$GITHUB_STEP_SUMMARY"
140141
exit 1
141142
fi
142143
143144
- if: github.event_name != 'workflow_dispatch'
144145
name: Use ref ${{github.ref_name}} as the basis for comparison
145146
run: |
146-
echo base=${{github.ref_name}} >> "$GITHUB_ENV"
147+
echo base="${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
147148
148149
- name: Check out a copy of the OpenFermion git repository
149150
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -350,12 +351,14 @@ jobs:
350351
runs-on: ubuntu-24.04
351352
steps:
352353
- run: |
353-
result="${{needs.pytest-matrix.result}}"
354+
result="${NEEDS_PYTEST_MATRIX_RESULT}"
354355
if [[ $result == "success" || $result == "skipped" ]]; then
355356
exit 0
356357
else
357358
exit 1
358359
fi
360+
env:
361+
NEEDS_PYTEST_MATRIX_RESULT: ${{needs.pytest-matrix.result}}
359362
360363
pytest-extra-matrix:
361364
if: needs.changes.outputs.python == 'true'
@@ -397,12 +400,14 @@ jobs:
397400
runs-on: ubuntu-24.04
398401
steps:
399402
- run: |
400-
result="${{needs.pytest-extra-matrix.result}}"
403+
result="${NEEDS_PYTEST_EXTRA_MATRIX_RESULT}"
401404
if [[ $result == "success" || $result == "skipped" ]]; then
402405
exit 0
403406
else
404407
exit 1
405408
fi
409+
env:
410+
NEEDS_PYTEST_EXTRA_MATRIX_RESULT: ${{needs.pytest-extra-matrix.result}}
406411
407412
python-compat:
408413
if: needs.changes.outputs.python == 'true'
@@ -465,7 +470,7 @@ jobs:
465470
runs-on: ubuntu-24.04
466471
timeout-minutes: 5
467472
env:
468-
changed_files: ${{needs.changes.outputs.yaml_files}}
473+
CHANGED_FILES: ${{needs.changes.outputs.yaml_files}}
469474
steps:
470475
- name: Check out a copy of the git repository
471476
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -477,7 +482,7 @@ jobs:
477482
run: |
478483
set -x
479484
# shellcheck disable=SC2086
480-
yamllint $changed_files
485+
yamllint ${CHANGED_FILES}
481486
482487
json-lint:
483488
if: needs.changes.outputs.json == 'true'
@@ -486,7 +491,7 @@ jobs:
486491
runs-on: ubuntu-24.04
487492
timeout-minutes: 5
488493
env:
489-
changed_files: ${{needs.changes.outputs.json_files}}
494+
CHANGED_FILES: ${{needs.changes.outputs.json_files}}
490495
steps:
491496
- name: Check out a copy of the git repository
492497
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -498,16 +503,16 @@ jobs:
498503
run: echo '::add-matcher::.github/problem-matchers/jsonlint.json'
499504

500505
- name: Run jsonlint on JSON files
501-
run: jsonlint --continue ${{env.changed_files}}
506+
run: |
507+
# shellcheck disable=SC2086
508+
jsonlint --continue ${CHANGED_FILES}
502509
503510
cff-validation:
504511
if: needs.changes.outputs.cff == 'true'
505512
name: CITATION.cff checks
506513
needs: changes
507514
runs-on: ubuntu-24.04
508515
timeout-minutes: 5
509-
env:
510-
changed_files: ${{needs.changes.outputs.cff_files}}
511516
steps:
512517
- name: Check out a copy of the git repository
513518
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -526,7 +531,7 @@ jobs:
526531
runs-on: macos-14
527532
timeout-minutes: 5
528533
env:
529-
changed_files: ${{needs.changes.outputs.docker_files}}
534+
CHANGED_FILES: ${{needs.changes.outputs.docker_files}}
530535
steps:
531536
- name: Check out a copy of the git repository
532537
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -540,7 +545,9 @@ jobs:
540545
run: echo '::add-matcher::.github/problem-matchers/hadolint.json'
541546

542547
- name: Run hadolint on Dockerfiles that have been changed
543-
run: hadolint ${{env.changed_files}}
548+
run: |
549+
# shellcheck disable=SC2086
550+
hadolint ${CHANGED_FILES}
544551
545552
workflow-validation:
546553
if: needs.changes.outputs.gha == 'true'
@@ -549,8 +556,6 @@ jobs:
549556
# This uses a Mac runner because actionlint isn't available via Linux apt.
550557
runs-on: macos-14
551558
timeout-minutes: 5
552-
env:
553-
changed_files: ${{needs.changes.outputs.gha_files}}
554559
steps:
555560
- name: Check out a copy of the git repository
556561
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -577,7 +582,7 @@ jobs:
577582
runs-on: ubuntu-24.04
578583
timeout-minutes: 5
579584
env:
580-
changed_files: ${{needs.changes.outputs.shell_files}}
585+
CHANGED_FILES: ${{needs.changes.outputs.shell_files}}
581586
steps:
582587
- name: Check out a copy of the git repository
583588
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -586,7 +591,9 @@ jobs:
586591
run: echo "::add-matcher::.github/problem-matchers/shellcheck.json"
587592

588593
- name: Run shellcheck on shell scripts that have been changed
589-
run: shellcheck ${{env.changed_files}}
594+
run: |
595+
# shellcheck disable=SC2086
596+
shellcheck ${CHANGED_FILES}
590597
591598
print-debugging-info:
592599
if: failure()

0 commit comments

Comments
 (0)