-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (69 loc) · 2.71 KB
/
codeql.yml
File metadata and controls
76 lines (69 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# SPDX-License-Identifier: PMPL-1.0-or-later
name: CodeQL Security Analysis
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
schedule:
- cron: '0 6 * * 1'
# Estate guardrail: cancel superseded runs so re-pushes don't pile up
# queued runs across the estate. Safe here because this workflow only
# performs read-only checks/lint/test/scan with no publish or mutation.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# The estate is heterogeneous (Rust, Idris2, Agda, Elixir, ReScript,
# occasional JS/TS/Python). A hard-coded `javascript-typescript` matrix
# made CodeQL exit with a "no source / configuration error" on every
# non-JS/TS repo — a permanent false-red `analyze` on most repos' main.
# Detect the languages the repo ACTUALLY contains and only analyse the
# CodeQL-supported, buildless-safe ones; skip entirely when none apply.
detect:
runs-on: ubuntu-latest
outputs:
langs: ${{ steps.pick.outputs.langs }}
steps:
- name: Pick CodeQL languages from repo language stats
id: pick
env:
GH_TOKEN: ${{ github.token }}
run: |
stats=$(gh api "repos/${{ github.repository }}/languages" --jq 'keys[]' 2>/dev/null || echo "")
out=""
add() { out="$out $1"; }
echo "$stats" | grep -qix 'Rust' && add rust
echo "$stats" | grep -qixE 'JavaScript|TypeScript' && add javascript-typescript
echo "$stats" | grep -qix 'Python' && add python
echo "$stats" | grep -qix 'Ruby' && add ruby
echo "$stats" | grep -qix 'Go' && add go
arr=$(printf '%s\n' $out | grep . | sort -u | jq -R . | jq -s -c .)
[ -z "$arr" ] && arr='[]'
echo "Detected CodeQL languages: $arr"
echo "langs=$arr" >> "$GITHUB_OUTPUT"
analyze:
needs: detect
if: needs.detect.outputs.langs != '[]'
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.detect.outputs.langs) }}
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Initialize CodeQL
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v3.28.1
with:
languages: ${{ matrix.language }}
build-mode: none
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v3.28.1
with:
category: "/language:${{ matrix.language }}"