File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 24
24
SONARCLOUD_HOST : https://sonarcloud.io
25
25
26
26
jobs :
27
+ token-check :
28
+ runs-on : ubuntu-latest
29
+ outputs :
30
+ hasToken : ${{ steps.check-token.outputs.has }}
31
+ steps :
32
+ - name : Check Token
33
+ id : check-token
34
+ run : |
35
+ [ -z $SONAR_TOKEN ] && echo "has=false" || echo "has=true" >> "$GITHUB_OUTPUT"
36
+ env :
37
+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
38
+
27
39
sonar :
28
40
name : SonarCloud Scan
29
41
runs-on : ubuntu-latest
30
- if : ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) }}
42
+ needs : token-check
43
+ if : ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/')) && needs.token-check.outputs.hasToken }}
31
44
steps :
32
45
- uses : actions/checkout@v4
33
46
with :
34
47
fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
35
48
36
49
- name : Set up JDK
37
- if : ${{ secrets.SONAR_TOKEN != '' }}
38
50
uses : actions/setup-java@v4
39
51
with :
40
52
distribution : ' temurin'
41
53
java-version : 17
42
54
43
55
- name : Cache SonarCloud packages
44
- if : ${{ secrets.SONAR_TOKEN != '' }}
45
56
uses : actions/cache@v4
46
57
with :
47
58
path : ~/.sonar/cache
48
59
key : ${{ runner.os }}-sonar
49
60
restore-keys : ${{ runner.os }}-sonar
50
61
51
62
- name : Cache Maven packages
52
- if : ${{ secrets.SONAR_TOKEN != '' }}
53
63
uses : actions/cache@v4
54
64
with :
55
65
path : ~/.m2
56
66
key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
57
67
restore-keys : ${{ runner.os }}-m2
58
68
59
69
- name : Build with Maven
60
- if : ${{ secrets.SONAR_TOKEN != '' }}
61
70
run : |
62
71
./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
63
72
-DskipTests \
You can’t perform that action at this time.
0 commit comments