Skip to content

Commit 954900d

Browse files
Merge pull request #39 from notion-dotnet/ci/38-add-sonar-cloud-analysis
Add SonarCloud analysis GitHub action 📈
2 parents 605889f + 8d4d2db commit 954900d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: SonarCLoud Analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
types: [opened, synchronize, reopened]
9+
10+
jobs:
11+
build:
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+
run: dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
39+
40+
- name: Build and analyze
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
43+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
44+
run: |
45+
./.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"
46+
dotnet restore
47+
dotnet build --no-restore
48+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)