-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (69 loc) · 2.31 KB
/
codeql.yml
File metadata and controls
82 lines (69 loc) · 2.31 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
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 6 * * 1' # Weekly Monday 6am UTC
permissions:
contents: read
jobs:
# Detect what files changed to skip CodeQL for docs-only PRs
changes:
runs-on: ubuntu-latest
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
# Always run on push to main and scheduled runs
if: github.event_name == 'pull_request'
with:
filters: |
code:
- 'src/**'
- 'tests/**'
- 'examples/**'
- 'benchmarks/**'
- '*.sln'
- 'Directory.*.props'
- 'Directory.Packages.props'
- name: Set output for non-PR events
id: non-pr
if: github.event_name != 'pull_request'
run: echo "code=true" >> $GITHUB_OUTPUT
analyze:
needs: changes
# Run on: push to main, scheduled, or PRs with code changes
if: github.event_name != 'pull_request' || needs.changes.outputs.code == 'true'
name: Analyze
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Initialize CodeQL
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
with:
languages: csharp
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '10.0.x'
- name: Cache NuGet packages
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore --locked-mode
- name: Build
run: dotnet build --no-restore -c Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4
with:
category: "/language:csharp"