-
Notifications
You must be signed in to change notification settings - Fork 606
69 lines (66 loc) · 1.57 KB
/
main.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: CI
on:
push:
branches:
- master
- feature_java17
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Maven Build
if: github.ref != 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-mvn
restore-keys: |
${{ runner.os }}-mvn-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: zulu
- name: Build with Maven
run: |
mvn verify \
--batch-mode \
--file portfolio-app/pom.xml
build-analyze:
name: Maven Build + Sonar Analysis
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache Maven repository
uses: actions/cache@v3
with:
path: |
~/.m2/repository
~/.sonar/cache
key: ${{ runner.os }}-mvn
restore-keys: |
${{ runner.os }}-mvn-
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: zulu
- name: Build with Maven
run: |
mvn verify sonar:sonar \
--batch-mode \
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
--file portfolio-app/pom.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}