Skip to content

Commit 8e32c7b

Browse files
authored
chore(ci): Move to zizmor action with stricter config (#4808)
This pull request primarily improves the security, clarity, and maintainability of the project's GitHub Actions workflows. The most significant changes include replacing the custom zizmor lint workflow with the official zizmor GitHub Action, updating permissions with explicit comments for better documentation, and upgrading action versions for enhanced security and reliability.
1 parent b20180a commit 8e32c7b

File tree

12 files changed

+87
-96
lines changed

12 files changed

+87
-96
lines changed

.github/workflows/actions.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/codeql.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ jobs:
1818
name: Analyze (${{ matrix.language }})
1919
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2020
permissions:
21-
# required for all workflows
22-
security-events: write
21+
security-events: write # required for CodeQL to upload security scan results
2322

2423
strategy:
2524
fail-fast: false
@@ -39,12 +38,12 @@ jobs:
3938

4039
# Initializes the CodeQL tools for scanning.
4140
- name: Initialize CodeQL
42-
uses: github/codeql-action/init@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.29.5
41+
uses: github/codeql-action/init@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.30.6
4342
with:
4443
languages: ${{ matrix.language }}
4544
build-mode: none
4645

4746
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@3599b3baa15b485a2e49ef411a7a4bb2452e7f93 # v3.29.5
47+
uses: github/codeql-action/analyze@64d10c13136e1c5bce3e5fbde8d4906eeaafc885 # v3.30.6
4948
with:
5049
category: "/language:${{matrix.language}}"

.github/workflows/dependency-review.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ permissions: {}
1313

1414
jobs:
1515
dependency-review:
16+
name: Dependency vulnerability scan
1617
runs-on: ubuntu-latest
1718
permissions:
18-
contents: read
19-
pull-requests: write
19+
contents: read # for actions/checkout
20+
pull-requests: write # for actions/dependency-review-action to comment on PRs
2021
steps:
2122
- name: Harden the runner (Audit all outbound calls)
2223
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1

.github/workflows/lambda.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ permissions:
1313

1414
jobs:
1515
build:
16+
name: Build and test lambda functions
1617
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
node: [22]
2018
container:
21-
image: node:${{ matrix.node }}
19+
image: node:22@sha256:2bb201f33898d2c0ce638505b426f4dd038cc00e5b2b4cbba17b069f0fff1496
2220
defaults:
2321
run:
2422
working-directory: ./lambdas

.github/workflows/ossf-scorecard.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ on:
77
push:
88
branches: [ "main" ]
99

10-
permissions: read-all
10+
permissions:
11+
contents: read # for actions/checkout and repository analysis
1112

1213
jobs:
1314
analysis:
1415
name: Scorecard analysis
1516
runs-on: ubuntu-latest
1617
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
1718
permissions:
18-
security-events: write
19-
id-token: write
19+
security-events: write # for github/codeql-action/upload-sarif to upload security scan results
20+
id-token: write # for ossf/scorecard-action to generate attestations
2021

2122
steps:
2223
- name: Harden the runner (Audit all outbound calls)
@@ -48,6 +49,6 @@ jobs:
4849
# Upload the results to GitHub's code scanning dashboard (optional).
4950
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
5051
- name: "Upload to code-scanning"
51-
uses: github/codeql-action/upload-sarif@3599b3baa15b485a2e49ef411a7a4bb2452e7f93
52+
uses: github/codeql-action/upload-sarif@dd196fa9ce80b6bacc74ca1c32bd5b0ba22efca7 # v3.28.3
5253
with:
5354
sarif_file: results.sarif

.github/workflows/release.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
name: Release
1515
runs-on: ubuntu-latest
1616
permissions:
17-
contents: write
18-
actions: write
19-
id-token: write
20-
attestations: write
17+
contents: write # for release-please-action to create releases and update changelogs
18+
actions: write # for release-please-action to trigger other workflows
19+
id-token: write # for actions/attest-build-provenance to generate attestations
20+
attestations: write # for actions/attest-build-provenance to write attestations
2121
steps:
2222
- name: Harden the runner (Audit all outbound calls)
2323
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -27,6 +27,7 @@ jobs:
2727
- uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0
2828
with:
2929
node-version: 22
30+
package-manager-cache: false
3031
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3132
with:
3233
persist-credentials: false
@@ -63,14 +64,16 @@ jobs:
6364
VERSION: ${{ github.event.inputs.version }}
6465
TAG_NAME: ${{ steps.release.outputs.tag_name }}
6566
ATTESTATION_URL: ${{ steps.attest.outputs.attestation-url }}
67+
REPOSITORY: ${{ github.repository }}
6668
run: |
6769
version="${VERSION}"
6870
tag_name="${TAG_NAME}"
6971
attestation_url="${ATTESTATION_URL}"
72+
repository="${REPOSITORY}"
7073
gh release view $version --json body -q '.body' > new-release-notes.md
7174
echo "## Attestation" >> new-release-notes.md
7275
echo "Attestation url: $attestation_url" >> new-release-notes.md
73-
echo "Verify the artifacts by running \`gh attestation verify <name_of_artifact> --repo ${{ github.repository }}\`" >> new-release-notes.md
76+
echo "Verify the artifacts by running \`gh attestation verify <name_of_artifact> --repo ${repository}\`" >> new-release-notes.md
7477
gh release edit $tag_name -F new-release-notes.md -t $tag_name
7578
- name: Upload release assets
7679
if: ${{ steps.release.outputs.releases_created == 'true' }}

.github/workflows/semantic-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ on:
66
- edited
77
- synchronize
88
permissions:
9-
contents: read
10-
pull-requests: read
9+
contents: read # for actions/checkout
10+
pull-requests: read # for amannn/action-semantic-pull-request to check PR details
1111
jobs:
1212
main:
1313
name: Semantic Commit Message Check

.github/workflows/stale.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ on:
33
schedule:
44
- cron: "30 1 * * *"
55
workflow_dispatch:
6-
permissions:
7-
issues: write
8-
pull-requests: write
6+
permissions: {}
97
jobs:
108
stale:
9+
name: Mark stale issues and PRs
1110
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write # for actions/stale to close stale issues
13+
pull-requests: write # for actions/stale to close stale PRs
1214
steps:
1315
- name: Harden the runner (Audit all outbound calls)
1416
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1

.github/workflows/terraform.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: Verify module
1717
strategy:
1818
matrix:
19-
terraform: [1.5.6, "latest"]
19+
terraform: ["1.5.6", "latest"]
2020
runs-on: ubuntu-latest
2121
container:
2222
image: hashicorp/terraform:${{ matrix.terraform }}
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
terraform: [1.5.6, "latest"]
77+
terraform: ["1.5.6", "latest"]
7878
module:
7979
[
8080
"ami-housekeeper",
@@ -132,16 +132,18 @@ jobs:
132132
- if: contains(matrix.terraform, '1.3.')
133133
name: Run TFLint
134134
working-directory: ${{ github.workspace }}
135+
env:
136+
MODULE_NAME: ${{ matrix.module }}
135137
run: |
136-
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir modules/${{ matrix.module }}
137-
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir modules/${{ matrix.module }}
138+
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir "modules/${MODULE_NAME}"
139+
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir "modules/${MODULE_NAME}"
138140
139141
verify_examples:
140142
name: Verify examples
141143
strategy:
142144
fail-fast: false
143145
matrix:
144-
terraform: [1.5.6, "latest"]
146+
terraform: ["1.5.6", "latest"]
145147
example:
146148
[
147149
"default",
@@ -195,6 +197,8 @@ jobs:
195197
- if: contains(matrix.terraform, '1.5.')
196198
name: Run TFLint
197199
working-directory: ${{ github.workspace }}
200+
env:
201+
EXAMPLE_NAME: ${{ matrix.example }}
198202
run: |
199-
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir modules/${{ matrix.module }}
200-
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir examples/${{ matrix.example }}
203+
tflint --init -c ${GITHUB_WORKSPACE}/.tflint.hcl --chdir "examples/${EXAMPLE_NAME}"
204+
tflint -f compact -c ${GITHUB_WORKSPACE}/.tflint.hcl --var-file ${GITHUB_WORKSPACE}/.github/lint/tflint.tfvars --chdir "examples/${EXAMPLE_NAME}"

.github/workflows/update-docs.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
name: Auto update terraform docs
1515
runs-on: ubuntu-latest
1616
permissions:
17-
contents: write
18-
pull-requests: write
17+
contents: write # for terraform-docs/gh-actions to commit documentation updates
18+
pull-requests: write # for peter-evans/create-pull-request to create PRs with doc updates
1919
steps:
2020
- name: Harden the runner (Audit all outbound calls)
2121
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
@@ -61,17 +61,20 @@ jobs:
6161
delete-branch: true
6262

6363
deploy-pages:
64+
name: Deploy documentation to GitHub Pages
6465
needs: [docs]
6566
runs-on: ubuntu-latest
6667
permissions:
67-
contents: write
68+
contents: write # for actions/checkout and mkdocs gh-deploy to push to gh-pages branch
6869
steps:
6970
- name: Harden the runner (Audit all outbound calls)
7071
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
7172
with:
7273
egress-policy: audit
7374

7475
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
76+
with:
77+
persist-credentials: false
7578
- name: Configure Git Credentials
7679
run: |
7780
git config user.name github-actions[bot]

0 commit comments

Comments
 (0)