From 18bcfe5f4f961cd2d5bb765852eb2ac9074dca4c Mon Sep 17 00:00:00 2001 From: Walt Date: Wed, 29 Nov 2023 15:44:32 -0700 Subject: [PATCH] Add GitHub Action to lint incoming GitHub Actions (#188) This workflow will check that all changed and added GitHub actions are either pinned to a hash, or on an allow list. This workflow is built to be reusable across Teleport repos, in addition to enforcing standards in this repo. --- .github/workflows/github-action-lint.yaml | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/github-action-lint.yaml diff --git a/.github/workflows/github-action-lint.yaml b/.github/workflows/github-action-lint.yaml new file mode 100644 index 00000000..9577720f --- /dev/null +++ b/.github/workflows/github-action-lint.yaml @@ -0,0 +1,37 @@ +on: + pull_request: + branches: + - main + workflow_call: + +name: Lint (GitHub Actions) + +jobs: + check-github-actions: + name: Check GitHub Actions + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check for affected paths + id: changes + uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1 + with: + filters: | + github-actions: + - '.github/*/**/*.{yaml,yml}' + + - name: Ensure SHA pinned actions + uses: zgosalvez/github-actions-ensure-sha-pinned-actions@b35f285b9bb7e80de0967367cee66d3b6d50ceca # v3.0.1 + if: steps.changes.outputs.github-actions == 'true' + with: + allowlist: | + github/ + actions/ + gravitational/shared-workflows/.github/workflows + gravitational/teleport/.github/workflows + gravitational/teleport.e/.github/workflows