Skip to content

Commit dca9c35

Browse files
committed
Add SonarCloud scan.
1 parent 129d7da commit dca9c35

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: SonarCloud
2+
on:
3+
push:
4+
branches:
5+
- master
6+
paths-ignore:
7+
- 'docs/**'
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
env:
12+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
13+
DOTNET_CLI_TELEMETRY_OPTOUT: 1
14+
15+
jobs:
16+
build:
17+
name: Scan
18+
runs-on: windows-latest
19+
steps:
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v1
22+
with:
23+
java-version: 1.11
24+
- name: Set up .NET 5.0
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: 5.0.x
28+
- uses: actions/checkout@v2
29+
with:
30+
fetch-depth: 0 # fetch all revisions
31+
- name: Cache SonarCloud packages
32+
uses: actions/cache@v1
33+
with:
34+
path: ~\sonar\cache
35+
key: ${{ runner.os }}-sonar
36+
restore-keys: ${{ runner.os }}-sonar
37+
- name: Cache SonarCloud scanner
38+
id: cache-sonar-scanner
39+
uses: actions/cache@v1
40+
with:
41+
path: .\.sonar\scanner
42+
key: ${{ runner.os }}-sonar-scanner
43+
restore-keys: ${{ runner.os }}-sonar-scanner
44+
- name: Install SonarCloud scanner
45+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
46+
shell: powershell
47+
run: |
48+
New-Item -Path .\.sonar\scanner -ItemType Directory
49+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
50+
- name: Restore Packages
51+
run: dotnet restore
52+
- name: Build and analyze
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
56+
shell: powershell
57+
run: |
58+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"mysql-net_MySqlConnector" /o:"mysql-net" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
59+
dotnet build --configuration Release --no-restore
60+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)