-
-
Notifications
You must be signed in to change notification settings - Fork 310
52 lines (49 loc) · 1.59 KB
/
build.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
name: Java CI with Maven
on:
push:
branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x, 3.2.x ]
pull_request:
branches: [ main, 2.3.x, 2.4.x, 3.0.x, 3.1.x, 3.2.x ]
permissions:
contents: read
jobs:
build:
name: Test with JDK ${{ matrix.version }}
strategy:
matrix:
version: [ 17.0.12, 21.0.4 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.version }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.version }}
cache: maven
- name: Build with Maven
run: ./mvnw -V -B verify -Pspring
sonar:
name: Run Sonar Analysis
runs-on: ubuntu-latest
# Disable Sonar for foreign PRs
if: (github.event_name != 'pull_request' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17.0.12
cache: maven
- name: Cache SonarCloud packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build with Maven
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./mvnw -V -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pcoverage,spring