Skip to content

Commit 50cdb57

Browse files
committed
ci: add GitHub Actions linter
1 parent 89aed9b commit 50cdb57

File tree

5 files changed

+83
-0
lines changed

5 files changed

+83
-0
lines changed
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Generated by Gabo (https://github.com/ashishb/gabo)
2+
---
3+
# Run this locally with act - https://github.com/nektos/act
4+
# act -j lintGitHubActions
5+
name: Lint GitHub Actions
6+
7+
on: # yamllint disable-line rule:truthy
8+
push:
9+
branches: [master, main]
10+
paths:
11+
- ".github/workflows/**.yml"
12+
- ".github/workflows/**.yaml"
13+
pull_request:
14+
branches: [master, main]
15+
paths:
16+
- ".github/workflows/**.yml"
17+
- ".github/workflows/**.yaml"
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
jobs:
24+
lintGitHubActionsWithActionLint:
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 15
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
with:
32+
persist-credentials: false
33+
sparse-checkout: |
34+
.github/workflows
35+
sparse-checkout-cone-mode: false
36+
37+
- name: Lint GitHub Actions
38+
uses: reviewdog/action-actionlint@v1
39+
40+
- name: Check GitHub Actions with 'actionlint'
41+
# Ref: https://github.com/rhysd/actionlint/blob/main/docs/usage.md#use-actionlint-on-github-actions
42+
# shellcheck is too noisy and disabled
43+
run: |
44+
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
45+
./actionlint -color -shellcheck=
46+
shell: bash
47+
48+
49+
lintGitHubActionsForSecurity:
50+
runs-on: ubuntu-latest
51+
timeout-minutes: 15
52+
53+
permissions:
54+
security-events: write
55+
contents: read
56+
actions: read
57+
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v4
61+
with:
62+
persist-credentials: false
63+
sparse-checkout: |
64+
.github/workflows
65+
sparse-checkout-cone-mode: false
66+
67+
- name: Setup Rust
68+
uses: actions-rust-lang/setup-rust-toolchain@v1
69+
70+
- name: Install zizmor
71+
run: cargo install zizmor
72+
73+
- name: Run zizmor on GitHub Actions
74+
run: zizmor .github/workflows/*

.github/workflows/lint-markdown.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
steps:
2828
- name: Checkout code
2929
uses: actions/checkout@v4
30+
with:
31+
persist-credentials: false
3032

3133
- name: Set up Ruby
3234
# See https://github.com/ruby/setup-ruby#versioning

.github/workflows/lint-shell-script.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
steps:
3131
- name: Checkout code
3232
uses: actions/checkout@v4
33+
with:
34+
persist-credentials: false
3335

3436
- name: Run ShellCheck
3537
uses: ludeeus/[email protected]

.github/workflows/lint-yaml.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
steps:
3232
- name: Checkout repository
3333
uses: actions/checkout@v4
34+
with:
35+
persist-credentials: false
36+
3437
- name: Check YAML files with linter
3538
uses: ibiqlik/action-yamllint@v3
3639
with:

.github/workflows/validate-links.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030

3131
- name: Checkout code
3232
uses: actions/checkout@v4
33+
with:
34+
persist-credentials: false
3335

3436
- uses: actions/cache@v4
3537
with:

0 commit comments

Comments
 (0)