@@ -4,20 +4,24 @@ name: Maven Build
4
4
on :
5
5
workflow_call :
6
6
inputs :
7
+ docker :
8
+ type : boolean
9
+ default : true
7
10
dockerhub_username :
8
11
type : string
9
- required : true
10
12
image_name :
11
13
type : string
12
- required : true
13
14
14
15
jobs :
15
16
build :
16
17
name : Maven Build
17
18
runs-on : ubuntu-latest
18
19
environment :
19
- name : Docker Hub
20
- url : https://hub.docker.com/layers/${{ inputs.image_name }}/${{ steps.bump.outputs.tag }}/images/${{ steps.docker_build_push.outputs.digest }}
20
+ name : Build # To isolate BUMP_PAT
21
+ url : ${{ steps.upload.outputs.artifact-url }}
22
+ outputs :
23
+ artifact_name : app-${{ steps.bump.outputs.tag }}
24
+ new_tag : ${{ steps.bump.outputs.tag }}
21
25
22
26
steps :
23
27
- name : Checkout
33
37
distribution : " liberica"
34
38
cache : " maven"
35
39
40
+ - name : Cache SonarQube packages
41
+ uses : actions/cache@v3
42
+ with :
43
+ path : ~/.sonar/cache
44
+ key : ${{ runner.os }}-sonar
45
+ restore-keys : ${{ runner.os }}-sonar
46
+
36
47
- name : Run Tests
37
48
run : mvn test -B -P prod "-Dstyle.color=always"
38
49
54
65
-Dsonar.organization=soat-tech-challenge \
55
66
-Dsonar.projectKey=soat-tech-challenge_$REPO_NAME
56
67
68
+ - name : Upload Artifact
69
+ id : upload
70
+ uses : actions/upload-artifact@v4
71
+ with :
72
+ name : app-${{ steps.bump.outputs.tag }}
73
+ path : target/app.jar
74
+ if-no-files-found : error
75
+
76
+ docker :
77
+ name : Docker Build and Push
78
+ if : ${{ inputs.docker == true || inputs.docker == 'true' }}
79
+ needs : build
80
+ runs-on : ubuntu-latest
81
+ environment :
82
+ name : Docker Hub
83
+ url : https://hub.docker.com/layers/${{ inputs.image_name }}/${{ needs.build.outputs.new_tag }}/images/${{ steps.docker_build_push.outputs.digest }}
84
+
85
+ steps :
86
+ - name : Checkout
87
+ uses : actions/checkout@v3
88
+
89
+ - name : Download Artifact
90
+ uses : actions/download-artifact@v4
91
+ with :
92
+ name : ${{ needs.build.outputs.artifact_name }}
93
+ path : target/app.jar
94
+
57
95
- name : Login to Docker Hub
58
96
uses : docker/login-action@v3
59
97
with :
66
104
with :
67
105
context : .
68
106
push : true
69
- tags : ${{ inputs.image_name }}:${{ steps.bump .outputs.tag }},${{ inputs.image_name }}:latest
107
+ tags : ${{ inputs.image_name }}:${{ needs.build .outputs.new_tag }},${{ inputs.image_name }}:latest
0 commit comments