Skip to content

Commit 44d60ba

Browse files
committed
switch to wcm-io-devops/github-action-maven-build-sonar@v1
1 parent b50cf01 commit 44d60ba

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

.github/workflows/maven-build.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,16 @@ jobs:
3232
distribution: temurin
3333

3434
steps:
35-
- name: Checkout code
36-
uses: actions/checkout@v2
35+
- name: Maven Build with SonarCloud
36+
uses: wcm-io-devops/github-action-maven-build-sonar@v1
3737
with:
38-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
39-
40-
- name: Setup JDK
41-
uses: actions/setup-java@v2
42-
with:
43-
distribution: ${{ matrix.distribution }}
38+
os: ${{ matrix.os }}
4439
java-version: ${{ matrix.java }}
45-
cache: 'maven'
46-
47-
- name: Cache SonarCloud packages
48-
uses: actions/cache@v1
49-
with:
50-
path: ~/.sonar/cache
51-
key: ${{ runner.os }}-sonar
52-
restore-keys: ${{ runner.os }}-sonar
53-
54-
- name: Build and verify
55-
run: ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B -U clean install
40+
maven-executable: ./mvnw
41+
sonar-run-on-os: ubuntu-latest
42+
sonar-run-on-java-version: 11
43+
sonar-token: ${{ secrets.SONAR_TOKEN }}
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
5645

5746
- name: Build and verify example
5847
run: ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B -U clean verify -f example
59-
60-
- name: Analyze in SonarCloud
61-
env:
62-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
63-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64-
# SONAR_TOKEN is not present when building for external PR
65-
run: ([ -z $SONAR_TOKEN ] || ./mvnw -s ./.maven-settings.xml -Pcontinuous-integration -B sonar:sonar -Dsonar.projectKey=${{github.repository_owner}}_${{github.event.repository.name}} -Dsonar.projectName=${{github.event.repository.name}})
66-
if: ${{ matrix.java == '11' && matrix.os == 'ubuntu-latest' }}

0 commit comments

Comments
 (0)