24
24
- " main"
25
25
26
26
jobs :
27
+ general_settings :
28
+ name : Set general settings
29
+ runs-on : ubuntu-latest
30
+ outputs :
31
+ EVENT_TYPE : ${{ steps.set_outputs.outputs.EVENT_TYPE }}
32
+ SHORT_SHA : ${{ steps.set_outputs.outputs.SHORT_SHA }}
33
+ steps :
34
+ - name : get_trigger_event
35
+ run : |
36
+ eventtype=${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
37
+ echo "EVENT_TYPE=${eventtype}" >> $GITHUB_ENV
38
+ - name : get_short_sha
39
+ run : |
40
+ sha=${{ github.sha }}
41
+ strip_sha=${sha:0:7}
42
+ echo "SHORT_SHA=${strip_sha}" >> $GITHUB_ENV
43
+
44
+ - name : set_outputs
45
+ id : set_outputs
46
+ run : |
47
+ echo "EVENT_TYPE=${{ env.EVENT_TYPE }}" >> $GITHUB_OUTPUT
48
+ echo "SHORT_SHA=${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT
49
+
27
50
# Build and run the test suite
28
51
build_and_test :
29
52
name : Build and run test image
30
53
runs-on : ubuntu-latest
54
+ needs : general_settings
31
55
strategy :
32
56
fail-fast : false
33
57
matrix :
@@ -59,11 +83,13 @@ jobs:
59
83
- name : Build test image
60
84
uses : ./.github/actions/docker-build-push-action
61
85
with :
62
- dockerfile : Dockerfile.${{ matrix.arch }}
86
+ dockerfile : Dockerfile
63
87
tags : ${{ steps.meta_test.outputs.tags }}
64
88
labels : ${{ steps.meta_test.outputs.labels }}
65
89
push : true
66
- build-args : TEST=true
90
+ build-args : |
91
+ ARCH=${{ matrix.arch }}
92
+ TEST=true
67
93
target : runtime-base
68
94
registry_user : ${{ secrets.ECOSYSTEM_SERVICE_USER_DOCKER_HUB }}
69
95
registry_token : ${{ secrets.ECOSYSTEM_ACCESS_TOKEN_DOCKER_HUB }}
@@ -92,30 +118,26 @@ jobs:
92
118
requirements_file : ./.github/test/requirements.txt
93
119
logfile : test_log_${{ matrix.arch }}.txt
94
120
95
- # Build base image and extract eap file then use ACAP portal to sign it
96
- # This job is skipped if not on main branch or if build_and_test job has failed
121
+ # Build base image and extract eap file
97
122
build :
98
123
name : Build acap
99
124
runs-on : ubuntu-latest
100
- needs : build_and_test
125
+ needs : general_settings
101
126
if : (github.event_name != 'pull_request')
102
127
strategy :
103
128
matrix :
104
129
arch : [armv7hf, aarch64]
130
+ env :
131
+ EVENT_TYPE : ${{ needs.general_settings.outputs.EVENT_TYPE }}
132
+ SHORT_SHA : ${{ needs.general_settings.outputs.SHORT_SHA }}
105
133
outputs :
106
134
EAP_FILE_ARMV7HF : ${{ steps.save_full_file_name.outputs.EAP_FILE_ARMV7HF }}
107
135
EAP_FILE_AARCH64 : ${{ steps.save_full_file_name.outputs.EAP_FILE_AARCH64 }}
108
- SHORT_SHA : ${{ steps.save_full_file_name.outputs.SHORT_SHA }}
109
136
steps :
110
137
- name : Checkout repo
111
138
uses : actions/checkout@v4
112
- - name : get_short_sha
113
- run : |
114
- sha=${{ github.sha }}
115
- strip_sha=${sha:0:7}
116
- echo "SHORT_SHA=${strip_sha}" >> $GITHUB_ENV
117
139
- uses : actions/cache@v4
118
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
140
+ if : ${{ env.EVENT_TYPE }}
119
141
with :
120
142
path : ${{ github.workspace }}/build-${{ matrix.arch }}
121
143
key : key-${{ env.SHORT_SHA }}-${{ github.run_id }}-${{ matrix.arch }}
@@ -128,7 +150,7 @@ jobs:
128
150
get_version : " true"
129
151
- name : Get changes for manifest
130
152
id : manifest-settings
131
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
153
+ if : ${{ env.EVENT_TYPE }}
132
154
run : |
133
155
if [ ${{github.ref_type}} == tag ]; then
134
156
echo "version_value=${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT
@@ -138,42 +160,43 @@ jobs:
138
160
echo "append_sha='true'" >> $GITHUB_OUTPUT
139
161
fi
140
162
- name : Update manifest file
141
- if : ( github.ref_type == 'tag')
163
+ if : ${{ env.EVENT_TYPE }}
142
164
uses : ./.github/actions/update-acap-manifest-action
143
165
with :
144
166
manifest_file : ./manifest-${{ matrix.arch }}.json
145
- append : ${{ steps.manifest-settings.outputs.append_sha}}
167
+ append : ${{ steps.manifest-settings.outputs.append_sha }}
146
168
value : ${{ steps.manifest-settings.outputs.version_value }}
147
- - name : Build and push base image
169
+ - name : Build eap file
148
170
uses : ./.github/actions/docker-build-push-action
149
171
with :
150
- dockerfile : Dockerfile.${{ matrix.arch }}
172
+ dockerfile : Dockerfile
151
173
tags : ${{ steps.meta.outputs.tags }}
152
174
labels : ${{ steps.meta.outputs.labels }}
153
- target : runtime-base
175
+ build-args : |
176
+ ARCH=${{ matrix.arch }}
177
+ target : binaries
154
178
push : false
155
179
load : true
180
+ outputs : " type=local,dest=build"
156
181
- name : Set name of EAP-file
157
182
id : get_eap_file_name
158
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
183
+ if : ${{ env.EVENT_TYPE }}
159
184
run : |
160
- docker cp $(docker create "${{ steps.meta.outputs.full_name }}"):/opt/app .build
161
- export EAP_FILE=$(find .build -type f -name "*.eap" -printf "%f\n")
185
+ export EAP_FILE=$(find build -type f -name "*.eap" -printf "%f\n")
162
186
delimiter="$(openssl rand -hex 8)"
163
187
echo "EAP_FILE<<${delimiter}" >> ${GITHUB_ENV}
164
188
echo "${EAP_FILE}" >> ${GITHUB_ENV}
165
189
echo "${delimiter}" >> ${GITHUB_ENV}
166
190
- name : Add sha to EAP-file name
167
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
191
+ if : ${{ env.EVENT_TYPE }}
168
192
run : |
169
193
eap_file_w_sha=$(echo $"${{ env.EAP_FILE }}" | sed 's/\.eap/_${{ env.SHORT_SHA }}.eap/')
170
194
echo "EAP_FILE_W_SHA=${eap_file_w_sha}" >> $GITHUB_ENV
171
195
cp build/${{ env.EAP_FILE }} build/$eap_file_w_sha
172
196
- name : Save full file name
173
197
id : save_full_file_name
174
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
198
+ if : ${{ env.EVENT_TYPE }}
175
199
run : |
176
- echo "SHORT_SHA=${{ env.SHORT_SHA }}" >> $GITHUB_OUTPUT
177
200
if [ ${{ matrix.arch }} = armv7hf ]
178
201
then
179
202
echo "EAP_FILE_ARMV7HF=${{ env.EAP_FILE_W_SHA }}" >> $GITHUB_OUTPUT
@@ -184,28 +207,28 @@ jobs:
184
207
echo "::error::Non valid architecture '${{ matrix.arch }}' encountered"
185
208
fi
186
209
- name : Move EAP-file to cache location
187
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
210
+ if : ${{ env.EVENT_TYPE }}
188
211
run : |
189
212
mkdir -p ${{ github.workspace }}/build-${{ matrix.arch }}
190
213
#rm -f ${{ github.workspace }}/build-${{ matrix.arch }}/${{ env.EAP_FILE_W_SHA }}
191
214
mv build/${{ env.EAP_FILE_W_SHA }} ${{ github.workspace }}/build-${{ matrix.arch }}/.
192
215
193
- # Sign the eap-file from the build
216
+ # Sign the eap-file from the build step
194
217
sign-eap :
195
218
runs-on : ubuntu-latest
196
- if : ${{ (github.ref_type == 'tag') || (github.event_name == 'push' && github.ref == 'refs/heads/main') }}
197
- needs : build
219
+ needs : [general_settings, build]
220
+ if : ${{ needs.general_settings.outputs.EVENT_TYPE }}
221
+ env :
222
+ EAP_FILE_ARMV7HF : ${{ needs.build.outputs.EAP_FILE_ARMV7HF }}
223
+ EAP_FILE_AARCH64 : ${{ needs.build.outputs.EAP_FILE_AARCH64 }}
224
+ SHORT_SHA : ${{ needs.general_settings.outputs.SHORT_SHA }}
198
225
permissions :
199
226
contents : write
200
227
strategy :
201
228
fail-fast : false
202
229
matrix :
203
230
arch : ["armv7hf", "aarch64"]
204
231
max-parallel : 1
205
- env :
206
- EAP_FILE_ARMV7HF : ${{ needs.build.outputs.EAP_FILE_ARMV7HF }}
207
- EAP_FILE_AARCH64 : ${{ needs.build.outputs.EAP_FILE_AARCH64 }}
208
- SHORT_SHA : ${{ needs.build.outputs.SHORT_SHA }}
209
232
outputs :
210
233
EAP_FILE_SIGNED_ARMV7HF : ${{ steps.save_full_file_name.outputs.EAP_FILE_SIGNED_ARMV7HF }}
211
234
EAP_FILE_SIGNED_AARCH64 : ${{ steps.save_full_file_name.outputs.EAP_FILE_SIGNED_AARCH64 }}
@@ -236,7 +259,7 @@ jobs:
236
259
echo "SIGNED_EAP_FILE=${signed_output}" >> $GITHUB_ENV
237
260
- name : Sign eap-file
238
261
run : |
239
- cd . build
262
+ cd build
240
263
RESPONSE=$(curl -XPOST -H 'accept: */*' -H 'Content-Type: multipart/form-data' \
241
264
-H 'Authorization: Bearer ${{secrets.ACAP_PORTAL_SIGNING_BEARER_TOKEN}}' \
242
265
'${{ vars.ACAP_PORTAL_URL }}/${{secrets.ACAP_PORTAL_SIGNING_ID}}/sign/binary' \
@@ -259,7 +282,7 @@ jobs:
259
282
uses : actions/upload-artifact@v4
260
283
with :
261
284
name : ${{ env.SIGNED_EAP_FILE }}
262
- path : . build/${{ env.SIGNED_EAP_FILE }}
285
+ path : build/${{ env.SIGNED_EAP_FILE }}
263
286
if-no-files-found : error
264
287
- name : Save file name
265
288
id : save_full_file_name
@@ -275,12 +298,10 @@ jobs:
275
298
fi
276
299
277
300
# Build containerized image and push to Docker Hub
278
- # This job is skipped if not on main branch or if build_and_test job has failed
279
- # It can (and should) run in parallel to the build_and_sign_acap job
280
301
build_containerized :
281
302
name : Build and push containerized images
282
303
runs-on : ubuntu-latest
283
- needs : [build_and_test, build]
304
+ needs : [general_settings, build_and_test, build]
284
305
if : (github.event_name != 'pull_request')
285
306
strategy :
286
307
matrix :
@@ -304,7 +325,7 @@ jobs:
304
325
- name : Build and push containerized image
305
326
uses : ./.github/actions/docker-build-push-action
306
327
with :
307
- dockerfile : Dockerfile.${{ matrix.arch }}
328
+ dockerfile : Dockerfile
308
329
tags : ${{ steps.meta_containerized.outputs.tags }}
309
330
labels : ${{ steps.meta_containerized.outputs.labels }}
310
331
push : true
0 commit comments