Skip to content

Commit 91160e7

Browse files
committed
feat(maven): add sonar
1 parent 675f17c commit 91160e7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/maven-and-docker-build.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,26 @@ jobs:
1818
distribution: "liberica"
1919
cache: "maven"
2020

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+
2128
- name: Verify with Maven
22-
run: mvn verify -B -P prod "-Dstyle.color=always"
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
31+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32+
run: |
33+
# Replace '/' with '_' to get project key
34+
PROJECT_KEY=${${{ github.repository }}//\//_}
35+
36+
mvn verify -B -P prod "-Dstyle.color=always" \
37+
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
38+
-Dsonar.host.url="https://sonarcloud.io" \
39+
-Dsonar.organization=${{ github.repository_owner }} \
40+
-Dsonar.projectKey=$PROJECT_KEY
2341
2442
- name: Build and push
2543
uses: docker/build-push-action@v5

0 commit comments

Comments
 (0)