Skip to content

Commit 9fd1d4a

Browse files
Fix CodeQL permissions and build script
1 parent b9e0b9e commit 9fd1d4a

File tree

1 file changed

+30
-25
lines changed

1 file changed

+30
-25
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,42 @@ on:
77
- 'dependabot/**'
88
pull_request:
99
schedule:
10-
- cron: '0 8 * * *'
10+
- cron: '0 8 * * 1'
1111
workflow_dispatch:
1212

1313
jobs:
1414
analyze:
1515
name: Analyze
1616
runs-on: ubuntu-latest
17+
permissions:
18+
actions: read
19+
contents: read
20+
security-events: write
21+
1722
steps:
18-
- name: Checkout repository
19-
uses: actions/checkout@v2
20-
21-
- name: Initialize CodeQL
22-
uses: github/codeql-action/init@v1
23-
with:
24-
queries: security-and-quality
25-
languages: csharp
26-
27-
- name: Build solution
28-
shell: pwsh
29-
run: |
30-
$buildConfiguration = "Release"
31-
$useSharedCompilation = "false"
32-
33-
Get-ChildItem src -Include *.csproj -Recurse | ForEach-Object {
34-
dotnet build $_.FullName `
35-
-property:UseSharedCompilation=$useSharedCompilation `
36-
--configuration $buildConfiguration `
37-
--no-incremental
38-
}
39-
40-
- name: Perform CodeQL Analysis
41-
uses: github/codeql-action/analyze@v1
23+
- name: Checkout repository
24+
uses: actions/checkout@v2
25+
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@v1
28+
with:
29+
queries: security-and-quality
30+
languages: csharp
31+
32+
- name: Build solution
33+
shell: pwsh
34+
run: |
35+
$start = (Get-Location).Path.Length + 1
36+
$sln = Join-Path '..' 'ApiVersioning.sln'
37+
$projects = Get-ChildItem src -Include *.csproj -Recurse | `
38+
ForEach-Object { $_.FullName.Substring($start) }
39+
$json = ConvertTo-Json(New-Object PSObject -Property @{solution=@{path=$sln;projects=$projects}})
40+
$obj = New-Item -Path 'obj' -ItemType Directory -Force
41+
$slnf = New-Item -Path (Join-Path $obj 'codeql.slnf') -ItemType File -Value $json -Force
42+
43+
dotnet build $slnf.FullName --configuration Release
44+
45+
- name: Perform CodeQL Analysis
46+
uses: github/codeql-action/analyze@v1
4247

4348
# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)

0 commit comments

Comments
 (0)