66# separate terms of service, privacy policy, and support
77# documentation.
88
9- name : CI build maven package
9+ name : CI maven build and sonar cloud scan
1010
1111on :
12+ # Trigger analysis when pushing in master or pull requests, and when creating
13+ # a pull request.
1214 push :
1315 branches :
14- - main
15- - develop
16- - branch-sonarcloud
16+ - main
17+ - branch-sonarcloud
1718 pull_request :
18- branches :
19- - main
19+ types :
20+ - opened
21+ - synchronize
22+ - reopened
2023
2124jobs :
2225 build :
23-
26+ name : Build
2427 runs-on : ubuntu-latest
25-
2628 steps :
27- - uses : actions/checkout@v3
28- - name : Set up JDK 11
29- uses : actions/setup-java@v3
30- with :
31- java-version : ' 11'
32- distribution : ' corretto'
33- cache : maven
34- - name : Build with Maven
35- run : mvn -P full,coverage,metadata -B package --file pom.xml
29+ - uses : actions/checkout@v3
30+ with :
31+ # Shallow clones should be disabled for a better relevancy of analysis
32+ fetch-depth : 0
33+ - name : Set up JDK 17
34+ uses : actions/setup-java@v3
35+ with :
36+ java-version : ' 17'
37+ distribution : ' corretto'
38+ cache : ' maven'
39+ - name : Cache Maven packages
40+ uses : actions/cache@v1
41+ with :
42+ path : ~/.m2
43+ key : ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
44+ restore-keys : ${{ runner.os }}-m2
45+ - name : Cache SonarCloud packages
46+ uses : actions/cache@v1
47+ with :
48+ path : ~/.sonar/cache
49+ key : ${{ runner.os }}-sonar
50+ restore-keys : ${{ runner.os }}-sonar
51+ - name : Maven version
52+ run : mvn -v
53+ env :
54+ # Needed to get some information about the pull request, if any
55+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
56+ # SonarCloud access token should be generated from https://sonarcloud.io/account/security/
57+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
58+ - name : Build and analyze
59+ run : mvn -B clean install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage,full,metadata,sonarfugerit -Dsonar.projectKey=fugerit-org_${{github.event.repository.name}}
60+ env :
61+ # Needed to get some information about the pull request, if any
62+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63+ # SonarCloud access token should be generated from https://sonarcloud.io/account/security/
64+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
3665
3766 # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
38- - name : Update dependency graph
39- uses : advanced-security/maven-dependency-submission-action@v3.0.2
67+ - name : Update dependency graph
68+ uses : advanced-security/maven-dependency-submission-action@v3.0.2
0 commit comments