-
Notifications
You must be signed in to change notification settings - Fork 5
85 lines (72 loc) · 2.26 KB
/
build.yaml
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
name: Build release candidate
on:
release:
types: [created]
branches:
- main
jobs:
check-version:
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get version
id: version
run: echo "version=$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Print version
run: echo ${{ steps.version.outputs.version }}
- uses: mukunku/[email protected]
name: Check tag existence
id: check-tag-exists
with:
tag: ${{ steps.version.outputs.version }}
- name: Tag verification
id: check-tag
run: |
if [[ "${{ steps.check-tag-exists.outputs.exists }}" == "true" ]]; then
echo "Nothing to tag/release, the tag ${{ steps.version.outputs.version }} already exists"
exit 1
fi
build-release:
runs-on: ubuntu-latest
steps:
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch
- uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
- name: Build API
run: mvn package -Dchangelist=-SNAPSHOT --no-transfer-progress
- name: Upload API jar
uses: actions/upload-artifact@v4
with:
name: app-jar
path: target/*.jar
docker:
needs:
- check-version
- build-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download uploaded jar
uses: actions/download-artifact@v4
with:
name: app-jar
path: target/
- name: Publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: inseefr/magma-back-office
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
tags: "latest, ${{ needs.check-version.outputs.release-version }}"