|
| 1 | +name: Lint workflows |
| 2 | + |
| 3 | +# Catches workflow YAML / shell-in-`run:` regressions at PR time so a |
| 4 | +# typo can't reach a release tag and surface only when a publish run |
| 5 | +# fails. Scoped to changes under `.github/workflows/**` to keep CI |
| 6 | +# overhead off unrelated PRs. |
| 7 | + |
| 8 | +on: |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - ".github/workflows/**" |
| 12 | + push: |
| 13 | + branches: |
| 14 | + - main |
| 15 | + paths: |
| 16 | + - ".github/workflows/**" |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + actionlint: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 27 | + |
| 28 | + # Pulls the matching actionlint binary release from GitHub Releases |
| 29 | + # via the upstream download script. The script is fetched by commit |
| 30 | + # SHA (not a mutable tag) and sha256-verified before it runs — this |
| 31 | + # closes Scorecard's "downloadThenRun not pinned by hash" gap. The |
| 32 | + # script then checksum-verifies the actionlint binary it pulls from |
| 33 | + # the matching release. |
| 34 | + # |
| 35 | + # To bump: change ACTIONLINT_VERSION, set ACTIONLINT_SCRIPT_SHA to the |
| 36 | + # commit the new tag points at (`gh api repos/rhysd/actionlint/commits/vX.Y.Z -q .sha`), |
| 37 | + # and update ACTIONLINT_SCRIPT_SHA256 to that file's sha256. |
| 38 | + # |
| 39 | + # Install dir is passed explicitly as the script's second positional |
| 40 | + # arg so the workflow doesn't couple to the script's internal default |
| 41 | + # of $PWD (which happens to be $GITHUB_WORKSPACE after checkout — |
| 42 | + # a coincidence, not a contract). |
| 43 | + - name: Install actionlint |
| 44 | + env: |
| 45 | + ACTIONLINT_VERSION: "1.7.7" |
| 46 | + ACTIONLINT_SCRIPT_SHA: "03d0035246f3e81f36aed592ffb4bebf33a03106" |
| 47 | + ACTIONLINT_SCRIPT_SHA256: "221d1d16c03e4e4fcd867de34104e8d479bdce20ccdfa553b9a5c0dc29bf6af2" |
| 48 | + ACTIONLINT_INSTALL_DIR: ${{ runner.temp }}/actionlint |
| 49 | + run: | |
| 50 | + mkdir -p "${ACTIONLINT_INSTALL_DIR}" |
| 51 | + script="${ACTIONLINT_INSTALL_DIR}/download-actionlint.bash" |
| 52 | + curl -fsSL -o "${script}" \ |
| 53 | + "https://raw.githubusercontent.com/rhysd/actionlint/${ACTIONLINT_SCRIPT_SHA}/scripts/download-actionlint.bash" |
| 54 | + echo "${ACTIONLINT_SCRIPT_SHA256} ${script}" | sha256sum -c - |
| 55 | + bash "${script}" "${ACTIONLINT_VERSION}" "${ACTIONLINT_INSTALL_DIR}" |
| 56 | + echo "${ACTIONLINT_INSTALL_DIR}" >> "${GITHUB_PATH}" |
| 57 | + "${ACTIONLINT_INSTALL_DIR}/actionlint" -version |
| 58 | +
|
| 59 | + # `-shellcheck=shellcheck` makes the shellcheck dependency explicit |
| 60 | + # rather than relying on actionlint's implicit lookup against the |
| 61 | + # runner image's $PATH; if the Ubuntu image ever drops shellcheck the |
| 62 | + # job fails loudly instead of silently degrading. |
| 63 | + - name: Run actionlint |
| 64 | + run: actionlint -color -shellcheck=shellcheck |
0 commit comments