88 - ' *' # Trigger on all tags
99 pull_request : { }
1010
11+ env :
12+ SONARQUBE_PROJECT : patrickfav_bytes-java
13+
1114jobs :
1215 build :
1316 runs-on : ubuntu-latest
1417
1518 steps :
1619 - name : Checkout Code
1720 uses : actions/checkout@v3
18- - name : Set up JDK 8
21+ with :
22+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
23+ - name : Cache SonarCloud packages
24+ uses : actions/cache@v3
25+ with :
26+ path : ~/.sonar/cache
27+ key : ${{ runner.os }}-sonar
28+ restore-keys : ${{ runner.os }}-sonar
29+ - name : Cache Maven
30+ id : cache-primes
31+ uses : actions/cache@v3
32+ with :
33+ path : ~/.m2
34+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
35+ restore-keys : ${{ runner.os }}-m2
36+ - name : Set up JDK 11
1937 uses : actions/setup-java@v3
2038 with :
21- java-version : ' 8'
22- distribution : ' adopt'
23- cache : ' maven'
39+ java-version : ' 11'
40+ distribution : ' temurin'
2441 - name : Build with Maven
25- run : ./mvnw -B clean package checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true
26- - name : Upload coverage reports to CodeCov
27- uses : codecov/codecov-action@v3
42+ run : ./mvnw -B clean verify checkstyle:checkstyle jacoco:report -DcommonConfig.jarSign.skip=true
43+ - name : Analyze with SonaQube
44+ env :
45+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
46+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
47+ run : mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=$SONARQUBE_PROJECT
2848
2949 deploy :
3050 needs : build
@@ -38,12 +58,18 @@ jobs:
3858 KEYSTORE_BASE64 : ${{ secrets.KEYSTORE_BASE64 }}
3959 run : |
4060 echo $KEYSTORE_BASE64 | base64 --decode > keystore.jks
61+ - name : Cache Maven
62+ id : cache-primes
63+ uses : actions/cache@v3
64+ with :
65+ path : ~/.m2
66+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
67+ restore-keys : ${{ runner.os }}-m2
4168 - name : Set up Maven Central Repository
4269 uses : actions/setup-java@v3
4370 with :
44- java-version : ' 8'
45- distribution : ' adopt'
46- cache : ' maven'
71+ java-version : ' 11'
72+ distribution : ' temurin'
4773 server-id : ossrh # Value of the distributionManagement/repository/id field of the pom.xml
4874 server-username : MAVEN_USERNAME # env variable for username in deploy
4975 server-password : MAVEN_PASSWORD # env variable for token in deploy
0 commit comments