-
Notifications
You must be signed in to change notification settings - Fork 1
37 lines (31 loc) · 998 Bytes
/
build-and-analyze.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Java CI with Maven and SonarCloud
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [opened, synchronize, reopened]
jobs:
build-and-analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Necessary for a comprehensive SonarCloud analysis
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'zulu'
- name: Cache Maven and SonarCloud packages
uses: actions/cache@v3
with:
path: |
~/.m2
~/.sonar/cache
key: ${{ runner.os }}-m2-sonar-${{ hashFiles('**/pom.xml') }}
- name: Build and analyze with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: mvn -B verify --file pom.xml org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -PcoverageReport