Skip to content

Commit a9aaf23

Browse files
committed
fix: add actions language, fix gate job, align with default template
- Add 'actions' language to matrix (scans workflow files for security issues) - Add 'packages: read' permission (required for CodeQL packs) - Use matrix include syntax with per-language build-mode - Rename gate job to 'all-checks' with jq pattern matching ci.yml - Stagger schedule cron to avoid thundering herd - Remove unnecessary submodules checkout
1 parent afc95c9 commit a9aaf23

File tree

1 file changed

+20
-27
lines changed

1 file changed

+20
-27
lines changed

.github/workflows/codeql.yml

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
- main
1515
- dev
1616
schedule:
17-
- cron: "0 0 * * 1"
17+
- cron: "27 12 * * 4"
1818

1919
concurrency:
2020
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
@@ -23,74 +23,67 @@ concurrency:
2323
permissions:
2424
contents: read
2525
security-events: write
26+
packages: read
2627
actions: read
2728

2829
jobs:
2930
analyze:
30-
name: CodeQL Analysis
31+
name: Analyze (${{ matrix.language }})
3132
runs-on: ubuntu-latest
3233
timeout-minutes: 30
3334

3435
strategy:
3536
fail-fast: false
3637
matrix:
37-
language: ["rust"]
38+
include:
39+
- language: actions
40+
build-mode: none
41+
- language: rust
42+
build-mode: none
3843

3944
steps:
4045
- name: Checkout repository
41-
uses: actions/checkout@v4
42-
with:
43-
submodules: true
46+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
4447

4548
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v4
49+
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
4750
with:
4851
languages: ${{ matrix.language }}
49-
build-mode: none
52+
build-mode: ${{ matrix.build-mode }}
5053
queries: security-extended
5154

5255
- name: Perform CodeQL Analysis
53-
uses: github/codeql-action/analyze@v4
56+
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
5457
with:
5558
category: "/language:${{ matrix.language }}"
5659

5760
shellcheck:
5861
name: Shell Script Lint
5962
runs-on: ubuntu-latest
6063
timeout-minutes: 5
61-
needs: analyze
6264

6365
permissions:
6466
contents: read
6567
security-events: write
6668

6769
steps:
6870
- name: Checkout repository
69-
uses: actions/checkout@v4
71+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
7072

7173
- name: Run ShellCheck
72-
uses: ludeeus/action-shellcheck@2.0.0
74+
uses: ludeeus/action-shellcheck@00cae500b08a931fb5698e11e79bfbd38e612a38 # 2.0.0
7375
with:
7476
scandir: "."
7577
format: gcc
7678
severity: warning
77-
continue-on-error: true
7879

79-
CodeQL:
80+
all-checks:
8081
name: CodeQL
81-
runs-on: ubuntu-latest
8282
needs: [analyze, shellcheck]
83-
if: always()
84-
83+
if: ${{ !cancelled() }}
84+
runs-on: ubuntu-latest
8585
steps:
86-
- name: Check all jobs succeeded
86+
- name: Conclusion
8787
run: |
88-
if [ "${{ needs.analyze.result }}" != "success" ]; then
89-
echo "CodeQL analysis failed"
90-
exit 1
91-
fi
92-
if [ "${{ needs.shellcheck.result }}" != "success" ]; then
93-
echo "ShellCheck lint failed"
94-
exit 1
95-
fi
96-
echo "All security checks passed!"
88+
jq -C <<< '${{ toJson(needs) }}'
89+
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'

0 commit comments

Comments
 (0)