Skip to content

Commit 3b43be1

Browse files
Create sonar-cloud-analysis.yml
1 parent e7c999c commit 3b43be1

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v1
17+
with:
18+
java-version: 1.11
19+
- uses: actions/checkout@v2
20+
21+
- name: Cache SonarCloud packages
22+
uses: actions/cache@v1
23+
with:
24+
path: ~\sonar\cache
25+
key: ${{ runner.os }}-sonar
26+
restore-keys: ${{ runner.os }}-sonar
27+
28+
- name: Cache SonarCloud scanner
29+
id: cache-sonar-scanner
30+
uses: actions/cache@v1
31+
with:
32+
path: .\.sonar\scanner
33+
key: ${{ runner.os }}-sonar-scanner
34+
restore-keys: ${{ runner.os }}-sonar-scanner
35+
36+
- name: Install SonarCloud scanner
37+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
38+
shell: pwsh
39+
run: |
40+
New-Item -Path .\.sonar\scanner -ItemType Directory
41+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
42+
43+
- name: Build and analyze
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
46+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
47+
shell: pwsh
48+
run: |
49+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"notion-dotnet_notion-sdk-net" /o:"notion-dotnet" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
50+
dotnet restore
51+
dotnet build --no-restore
52+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)