Repository navigation
89 lines (84 loc) · 3.8 KB
/
Copy pathcodeql.yml
File metadata and controls
89 lines (84 loc) · 3.8 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
77
78
79
80
81
82
83
84
85
86
87
88
89
# ─────────────────────────────────────────────────────────────────────────────
# CodeQL — advanced setup (#1871, merge-queue prerequisite for #1864)
#
# WHY THIS EXISTS: code scanning was previously GitHub **default setup**, which
# analyzes `push` and `pull_request` only and can never post a result to the
# merge queue's `gh-readonly-queue/*` ref — default setup cannot be given extra
# triggers. So the required `CodeQL` check and a working merge queue were
# mutually exclusive (github/codeql-action#1537). This advanced-setup workflow
# adds the `merge_group` trigger so the `CodeQL` status check reports on the
# queue ref, while preserving the prior default-setup coverage: languages
# `actions` + `python`, `extended` (security-extended) query suite.
#
# ⚠️ REQUIRED MANUAL CUTOVER (repository setting, not a file change): when this
# lands, **disable code-scanning default setup** in
# Settings → Code security → Code scanning (set "CodeQL analysis" to advanced /
# disable default setup). Otherwise default and advanced setup both run.
#
# The required-check context produced here is `CodeQL` (the code-scanning
# results check the analyze step uploads) — do NOT rename it; the branch/merge-
# queue ruleset matches the required check by context name.
# ─────────────────────────────────────────────────────────────────────────────
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
# Required status check: must report on the merge queue's gh-readonly-queue/*
# ref, or the queue wedges (#1871, prerequisite for #1864).
merge_group:
permissions: {}
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
security-events: write
# Required for github/codeql-action/analyze to upload SARIF results in
# private/internal repositories; without it the CodeQL check fails.
actions: read
# Needed to fetch internal/private CodeQL packs when applicable.
packages: read
strategy:
fail-fast: false
matrix:
# Preserve the language set from the prior default setup.
language: [actions, python]
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@977e6ceaea7361825998245d787fa3b4d6b9e5df # codeql-bundle-v2.27.0
with:
languages: ${{ matrix.language }}
# `actions` and `python` are interpreted — no compilation step.
build-mode: none
# Matches the prior default-setup "extended" suite.
queries: security-extended
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@977e6ceaea7361825998245d787fa3b4d6b9e5df # codeql-bundle-v2.27.0
with:
category: /language:${{ matrix.language }}
CodeQL:
name: CodeQL
needs: analyze
if: always()
runs-on: ubuntu-latest
steps:
# Fail closed: only a fully successful matrix passes. `cancelled` and
# `skipped` runs completed no scan, so they must not report green.
- env:
ANALYZE_RESULT: ${{ needs.analyze.result }}
run: |
if [[ "${ANALYZE_RESULT}" != "success" ]]; then
echo "CodeQL analyze result: ${ANALYZE_RESULT} (expected success)" >&2
exit 1
fi