-
Notifications
You must be signed in to change notification settings - Fork 704
57 lines (48 loc) · 1.76 KB
/
codeql-analysis.yml
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
name: "CodeQL"
on:
push:
branches-ignore:
- 'dependabot/**'
pull_request:
schedule:
- cron: '0 8 * * 1'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
queries: security-and-quality
languages: csharp
- name: Setup .NET
uses: actions/setup-dotnet@v3
id: installdotnet
with:
dotnet-version: 8.0.x
- name: Create temporary global.json
run: echo '{"sdk":{"version":"${{ steps.installdotnet.outputs.dotnet-version }}"}}' > ./global.json
# build a temporary *.slnf file that only contains source projects and put it in ~/obj
# so that it is not tracked by git. then run 'dotnet build' using the *.slnf, which
# will preserve the dependency order and configuration of the *.sln
- name: Build Source
shell: pwsh
run: |
$start = (Get-Location).Path.Length + 1
$sln = Join-Path '..' 'asp.sln'
$projects = Get-ChildItem src -Include src -Recurse | `
ForEach-Object { Get-ChildItem $_.FullName -Filter *.csproj -Recurse } | `
ForEach-Object { $_.FullName.Substring($start) }
$json = ConvertTo-Json(New-Object PSObject -Property @{solution=@{path=$sln;projects=$projects}})
$obj = New-Item -Path 'obj' -ItemType Directory -Force
$slnf = New-Item -Path (Join-Path $obj 'codeql.slnf') -ItemType File -Value $json -Force
dotnet build $slnf.FullName --configuration Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2