Skip to content

Commit 740cf0b

Browse files
authored
Adding workflow to check code quality via sonarqube.
1 parent 3e2ae49 commit 740cf0b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/build.yml

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

0 commit comments

Comments
 (0)