-
Notifications
You must be signed in to change notification settings - Fork 3
114 lines (107 loc) · 3.38 KB
/
maven-build-test.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Build with Maven
on:
workflow_call:
inputs:
java-version:
description: 'Java version to use for building'
required: false
type: string
default: '17'
java-distribution:
description: 'Java distribution to use for building'
required: false
type: string
default: 'temurin'
maven-args:
description: 'Additional arguments to pass to maven'
required: false
type: string
default: ''
use-secrets:
description: 'Whether to use secrets or not'
required: false
type: boolean
default: false
maven-phase:
description: 'Maven phase to run'
required: false
type: string
default: 'verify'
login-docker:
description: 'Whether to log into the private docker hub'
required: false
type: boolean
default: false
secrets:
NEXUS_USERNAME:
required: true
NEXUS_PASSWORD:
required: true
DOCKER_HUB_USERNAME:
required: false
DOCKER_HUB_PASSWORD:
required: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- uses: actions/checkout@v4
- name: Set up JDK ${{ inputs.java-version }}
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.java-distribution }}
cache: 'maven'
- name: Set settings.xml
if: ${{ inputs.use-secrets }}
uses: s4u/maven-settings-action@v3.0.0
with:
servers: |
[{
"id": "mks-private-repo",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
},
{
"id": "mks-nexus-private",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
},
{
"id": "mks-nexus-public-snapshots",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
},
{
"id": "mks-nexus-public-releases",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
},
{
"id": "mks-nexus-private-snapshots",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
},
{
"id": "mks-nexus-private-releases",
"username": "${{ secrets.NEXUS_USERNAME }}",
"password": "${{ secrets.NEXUS_PASSWORD }}"
}]
- name: Login to Docker Hub
uses: docker/login-action@v3
if: ${{ inputs.login-docker }}
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build with Maven
run: 'mvn --batch-mode --no-transfer-progress --update-snapshots clean ${{ inputs.maven-phase }} ${{ inputs.maven-args }}'