-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (182 loc) · 6.19 KB
/
ci-full.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# This workflow will build a Quarkus project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: 👷 CI pipeline 🚀
# This section allows the workflow to create a Release
# https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
permissions:
checks: write
contents: write
pull-requests: write
# This section ensures that new pushes cancel current executions of the workflow
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
# Enabled manual triggering as this repo does not include a Quarkus/Maven repository
# Comment to disable manual triggering
on: workflow_dispatch
# Uncomment following lines to enable this workflow in a Quarkus/Maven repository
#on:
# push:
# branches:
# - main
# tags:
# - 'v[0-9]+.[0-9]+.[0-9]+'
# paths-ignore:
# - 'argocd/**'
# - 'img/**'
# - 'LICENSE'
# - '*.md'
env:
JAVA_VERSION: "17"
IMAGE_BASE_NAME: "quay.io/rmarting/kafka-clients-quarkus-sample"
jobs:
setup:
runs-on: ubuntu-latest
name: Get Application Version
outputs:
app_version: ${{ steps.get_app_version.outputs.version }}
tag_version: ${{ steps.get_tag_version.outputs.version }}
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: Get version from Maven project
id: get_app_version
run: |
APP_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Application Version: $APP_VERSION"
echo "version=$APP_VERSION" >> $GITHUB_OUTPUT
- name: Get version from Tag release
id: get_tag_version
if: startsWith(github.ref, 'refs/tags/')
run: |
echo "Application version from Tag release: ${{ github.ref_name }}"
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
name: "Compile"
needs:
- setup
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: Build with Maven
run: |
echo "Building version ${{ needs.setup.outputs.app_version }}"
./mvnw -B package --file pom.xml
#- name: Official SonarQube Scan
# uses: SonarSource/sonarqube-scan-action@v1.0.0
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: target/surefire-reports/**/*.xml
build-jvm:
runs-on: ubuntu-latest
needs:
- setup
- build
name: "Build Artifact"
steps:
- name: "Checkout the code"
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: "Build executable"
run: ./mvnw install --no-transfer-progress -DskipTests
- name: "Upload executable"
uses: actions/upload-artifact@v3
with:
name: executable
path: target/quarkus-app/*
push-image:
runs-on: ubuntu-latest
needs:
- setup
- build-jvm
name: "Push Image to Image Registry"
steps:
- name: "Checkout the code"
uses: actions/checkout@v3
- name: "Download the native executable"
uses: actions/download-artifact@v3
with:
name: executable
path: target/quarkus-app/
- name: "Login to Image Registry"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_REPO_USERNAME }}
password: ${{ secrets.QUAY_REPO_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v4
with:
push: true
context: .
file: src/main/docker/Dockerfile.jvm
# Hack for pseudo ternary expression: If no tag => Latest, if not, tag value
# Source: https://github.com/orgs/community/discussions/25725#discussioncomment-3248924
tags: ${{ env.IMAGE_BASE_NAME }}:${{ needs.setup.outputs.tag_version || needs.setup.outputs.app_version }}
build-native:
runs-on: ubuntu-latest
needs:
- setup
- push-image
name: "Build Native Artifact"
steps:
- name: "Checkout the code"
uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'adopt'
- name: "Build native executable"
run: ./mvnw install --no-transfer-progress -Dnative -DskipTests -Dquarkus.native.remote-container-build=true
- name: "Upload native executable"
uses: actions/upload-artifact@v3
with:
name: native-executable
path: target/*-runner
push-image-native:
runs-on: ubuntu-latest
needs:
- setup
- build-native
name: "Push Native Image to Image Registry"
steps:
- name: "Checkout the code"
uses: actions/checkout@v3
- name: "Download the native executable"
uses: actions/download-artifact@v3
with:
name: native-executable
path: target
- name: "Login to Image Registry"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_REPO_USERNAME }}
password: ${{ secrets.QUAY_REPO_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v4
with:
push: true
context: .
file: src/main/docker/Dockerfile.native
# Hack for pseudo ternary expression: If no tag => Latest, if not, tag value
# Source: https://github.com/orgs/community/discussions/25725#discussioncomment-3248924
tags: ${{ env.IMAGE_BASE_NAME }}:${{ needs.setup.outputs.tag_version || needs.setup.outputs.app_version }}-native