|
| 1 | +name: actionlint |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - '.github/workflows/*.ya?ml' |
| 9 | + pull_request: |
| 10 | + paths: |
| 11 | + - '.github/workflows/*.ya?ml' |
| 12 | + |
| 13 | +defaults: |
| 14 | + run: |
| 15 | + shell: bash -xeuo pipefail {0} |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: "actionlint-${{ github.ref }}" |
| 19 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 20 | + |
| 21 | +env: |
| 22 | + HOMEBREW_DEVELOPER: 1 |
| 23 | + HOMEBREW_NO_AUTO_UPDATE: 1 |
| 24 | + HOMEBREW_NO_ENV_HINTS: 1 |
| 25 | + |
| 26 | +permissions: {} |
| 27 | + |
| 28 | +# FIXME: The `Install tools` step fails inside the Docker container for some reason. |
| 29 | +jobs: |
| 30 | + workflow_syntax: |
| 31 | + if: github.repository_owner == 'Homebrew' |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + - name: Set up Homebrew |
| 35 | + id: setup-homebrew |
| 36 | + uses: Homebrew/actions/setup-homebrew@master |
| 37 | + with: |
| 38 | + core: true |
| 39 | + cask: false |
| 40 | + test-bot: false |
| 41 | + |
| 42 | + - name: Install tools |
| 43 | + run: brew install actionlint shellcheck zizmor |
| 44 | + |
| 45 | + - name: Set up GITHUB_WORKSPACE |
| 46 | + env: |
| 47 | + HOMEBREW_TAP_REPOSITORY: ${{ steps.setup-homebrew.outputs.repository-path }} |
| 48 | + run: | |
| 49 | + # Annotations work only relative to GITHUB_WORKSPACE |
| 50 | + (shopt -s dotglob; rm -rf "${GITHUB_WORKSPACE:?}"/*; mv "${HOMEBREW_TAP_REPOSITORY:?}"/* "$GITHUB_WORKSPACE") |
| 51 | + rmdir "$HOMEBREW_TAP_REPOSITORY" |
| 52 | + ln -vs "$GITHUB_WORKSPACE" "$HOMEBREW_TAP_REPOSITORY" |
| 53 | +
|
| 54 | + - run: zizmor --format sarif . > results.sarif |
| 55 | + |
| 56 | + - name: Upload SARIF file |
| 57 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 58 | + with: |
| 59 | + name: results.sarif |
| 60 | + path: results.sarif |
| 61 | + |
| 62 | + - name: Set up actionlint |
| 63 | + run: | |
| 64 | + # Setting `shell: /bin/bash` prevents shellcheck from running on |
| 65 | + # those steps, so let's change them to `shell: bash` for linting. |
| 66 | + sed -i 's|shell: /bin/bash -x|shell: bash -x|' .github/workflows/*.y*ml |
| 67 | + # The JSON matcher needs to be accessible to the container host. |
| 68 | + cp "$(brew --repository)/.github/actionlint-matcher.json" "$HOME" |
| 69 | + echo "::add-matcher::$HOME/actionlint-matcher.json" |
| 70 | +
|
| 71 | + - run: actionlint |
| 72 | + |
| 73 | + upload_sarif: |
| 74 | + needs: workflow_syntax |
| 75 | + runs-on: ubuntu-latest |
| 76 | + permissions: |
| 77 | + contents: read |
| 78 | + security-events: write |
| 79 | + steps: |
| 80 | + - name: Download SARIF file |
| 81 | + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 |
| 82 | + with: |
| 83 | + name: results.sarif |
| 84 | + path: results.sarif |
| 85 | + |
| 86 | + - name: Upload SARIF file |
| 87 | + uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10 |
| 88 | + with: |
| 89 | + sarif_file: results.sarif |
| 90 | + category: zizmor |
0 commit comments