4
4
push :
5
5
branches :
6
6
- main
7
- - ' release/**'
7
+ - " release/**"
8
8
tags :
9
9
- " v*"
10
10
11
- # Only run for pull requests if relevant files were changed
11
+ # Run when there is a label change on the pull request
12
+ # This runs only if the 'Z-Build-Workflow' is added to the pull request
12
13
pull_request :
13
- branches :
14
- - main
15
- - ' release/**'
14
+ types : [labeled]
16
15
17
16
concurrency :
18
17
group : ${{ github.workflow }}-${{ github.ref }}
31
30
jobs :
32
31
compute-version :
33
32
name : Compute version using git describe
33
+ if : github.event_name == 'push' || github.event.label.name == 'Z-Build-Workflow'
34
34
runs-on : ubuntu-24.04
35
+
36
+ permissions :
37
+ contents : read
38
+
35
39
outputs :
36
40
describe : ${{ steps.git.outputs.describe }}
37
41
timestamp : ${{ steps.git.outputs.timestamp }}
42
+
38
43
steps :
39
44
- name : Checkout the code
40
45
50
55
51
56
build-assets :
52
57
name : Build assets
58
+ if : github.event_name == 'push' || github.event.label.name == 'Z-Build-Workflow'
53
59
runs-on : ubuntu-24.04
54
60
55
61
permissions :
81
87
82
88
build-binaries :
83
89
name : Build binaries
90
+ if : github.event_name == 'push' || github.event.label.name == 'Z-Build-Workflow'
84
91
runs-on : ubuntu-24.04
85
92
86
93
needs :
@@ -139,6 +146,7 @@ jobs:
139
146
140
147
assemble-archives :
141
148
name : Assemble release archives
149
+ if : github.event_name == 'push' || github.event.label.name == 'Z-Build-Workflow'
142
150
runs-on : ubuntu-24.04
143
151
144
152
needs :
@@ -193,6 +201,7 @@ jobs:
193
201
194
202
build-image :
195
203
name : Build and push Docker image
204
+ if : github.event_name == 'push' || github.event.label.name == 'Z-Build-Workflow'
196
205
runs-on : ubuntu-24.04
197
206
198
207
outputs :
@@ -221,6 +230,7 @@ jobs:
221
230
latest=auto
222
231
tags : |
223
232
type=ref,event=branch
233
+ type=ref,event=pr
224
234
type=semver,pattern={{version}}
225
235
type=semver,pattern={{major}}.{{minor}}
226
236
type=semver,pattern={{major}}
@@ -237,6 +247,7 @@ jobs:
237
247
suffix=-debug,onlatest=true
238
248
tags : |
239
249
type=ref,event=branch
250
+ type=ref,event=pr
240
251
type=semver,pattern={{version}}
241
252
type=semver,pattern={{major}}.{{minor}}
242
253
type=semver,pattern={{major}}
@@ -252,6 +263,7 @@ jobs:
252
263
latest=auto
253
264
tags : |
254
265
type=ref,event=branch
266
+ type=ref,event=pr
255
267
type=semver,pattern={{version}}
256
268
type=semver,pattern={{major}}.{{minor}}
257
269
type=semver,pattern={{major}}
@@ -268,31 +280,15 @@ jobs:
268
280
mirrors = ["mirror.gcr.io"]
269
281
270
282
- name : Login to GitHub Container Registry
271
- if : github.event_name != 'pull_request'
272
283
273
284
with :
274
285
registry : ghcr.io
275
286
username : ${{ github.repository_owner }}
276
287
password : ${{ secrets.GITHUB_TOKEN }}
277
288
278
- # For pull-requests, only read from the cache, do not try to push to the
279
- # cache or the image itself
280
- - name : Build
281
-
282
- if : github.event_name == 'pull_request'
283
- with :
284
- files : |
285
- ./docker-bake.hcl
286
- cwd://${{ steps.meta.outputs.bake-file }}
287
- cwd://${{ steps.meta-debug.outputs.bake-file }}
288
- cwd://${{ steps.meta-syn2mas.outputs.bake-file }}
289
- set : |
290
- base.cache-from=type=registry,ref=${{ env.BUILDCACHE }}:buildcache
291
-
292
289
- name : Build and push
293
290
id : bake
294
291
295
- if : github.event_name != 'pull_request'
296
292
with :
297
293
files : |
298
294
./docker-bake.hcl
@@ -334,13 +330,12 @@ jobs:
334
330
syn2mas :
335
331
name : Release syn2mas on NPM
336
332
runs-on : ubuntu-24.04
333
+ if : github.event_name != 'pull_request'
337
334
338
335
permissions :
339
336
contents : read
340
337
id-token : write
341
338
342
- if : github.event_name != 'pull_request'
343
-
344
339
steps :
345
340
- name : Checkout the code
346
341
@@ -428,14 +423,16 @@ jobs:
428
423
429
424
unstable :
430
425
name : Update the unstable release
426
+ if : github.ref == 'refs/heads/main'
431
427
runs-on : ubuntu-24.04
428
+
432
429
needs :
433
430
- assemble-archives
434
431
- build-image
435
- if : github.ref == 'refs/heads/main'
436
432
437
433
permissions :
438
434
contents : write
435
+
439
436
steps :
440
437
- name : Checkout the code
441
438
@@ -460,7 +457,7 @@ jobs:
460
457
- name : Update unstable release
461
458
uses : softprops/action-gh-release@v2
462
459
with :
463
- name : ' Unstable build'
460
+ name : " Unstable build"
464
461
tag_name : unstable
465
462
body : |
466
463
This is an automatically updated unstable release containing the latest builds from the main branch.
@@ -501,3 +498,31 @@ jobs:
501
498
artifacts/mas-cli-x86_64-linux.tar.gz
502
499
prerelease : true
503
500
make_latest : false
501
+
502
+ pr-cleanup :
503
+ name : " Remove workflow build PR label and comment on it"
504
+ runs-on : ubuntu-24.04
505
+ if : github.event_name == 'pull_request' && github.event.label.name == 'Z-Build-Workflow'
506
+
507
+ needs :
508
+ - build-image
509
+
510
+ permissions :
511
+ contents : read
512
+ pull-requests : write
513
+
514
+ steps :
515
+ - name : Checkout the code
516
+
517
+ with :
518
+ sparse-checkout : |
519
+ .github/scripts
520
+
521
+ - name : Remove label and comment
522
+
523
+ env :
524
+ BUILD_IMAGE_MANIFEST : ${{ needs.build-image.outputs.metadata }}
525
+ with :
526
+ script : |
527
+ const script = require('./.github/scripts/cleanup-pr.cjs');
528
+ await script({ core, github, context });
0 commit comments