Skip to content

Commit 1ba67a0

Browse files
authored
Create build.yml
1 parent 29c6aa0 commit 1ba67a0

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/build.yml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: SonarCloud
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
jobs:
9+
build:
10+
name: Build and analyze
11+
runs-on: windows-latest
12+
steps:
13+
- name: Set up JDK 17
14+
uses: actions/setup-java@v3
15+
with:
16+
java-version: 17
17+
distribution: 'zulu' # Alternative distribution options are available.
18+
- uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21+
- name: Cache SonarCloud packages
22+
uses: actions/cache@v3
23+
with:
24+
path: ~\sonar\cache
25+
key: ${{ runner.os }}-sonar
26+
restore-keys: ${{ runner.os }}-sonar
27+
- name: Cache SonarCloud scanner
28+
id: cache-sonar-scanner
29+
uses: actions/cache@v3
30+
with:
31+
path: .\.sonar\scanner
32+
key: ${{ runner.os }}-sonar-scanner
33+
restore-keys: ${{ runner.os }}-sonar-scanner
34+
- name: Install SonarCloud scanner
35+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
36+
shell: powershell
37+
run: |
38+
New-Item -Path .\.sonar\scanner -ItemType Directory
39+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
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+
shell: powershell
45+
run: |
46+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"lyw912_downkyi" /o:"lyw912" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
47+
dotnet build
48+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)