44
44
binary_cache_hit : ${{ steps.binary-cache.outputs.cache-hit }}
45
45
ic_version : ${{ steps.vars.outputs.ic_version }}
46
46
publish-images : ${{ steps.vars.outputs.publish }}
47
+ docker_md5 : ${{ steps.vars.outputs.docker_md5 }}
47
48
steps :
48
49
- name : Checkout Repository
49
50
uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
90
91
publish=true
91
92
fi
92
93
echo "publish=$publish" >> $GITHUB_OUTPUT
94
+ docker_md5=$(find . -type f \( -name "build/Dockerfile" -o -name .github/data/version.txt \) -not -path "./docs*" -exec md5sum {} + | LC_ALL=C sort | md5sum | awk '{ print $1 }' )
95
+ echo "docker_md5=${docker_md5:0:8}" >> $GITHUB_OUTPUT
93
96
cat $GITHUB_OUTPUT
94
97
95
98
- name : Fetch Cached Binary Artifacts
@@ -228,17 +231,63 @@ jobs:
228
231
key : nginx-ingress-${{ needs.checks.outputs.go_code_md5 }}
229
232
if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
230
233
234
+ rebuild-base-images :
235
+ name : Rebuild NIC Base images
236
+ runs-on : ubuntu-22.04
237
+ needs : checks
238
+ permissions :
239
+ contents : read
240
+ id-token : write
241
+ steps :
242
+ - name : Checkout Repository
243
+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
244
+
245
+ - name : Docker Buildx
246
+ uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
247
+ if : github.event.pull_request.head.repo.full_name == github.repository
248
+
249
+ - name : Authenticate to Google Cloud
250
+ id : auth
251
+ uses : google-github-actions/auth@a6e2e39c0a0331da29f7fd2c2a20a427e8d3ad1f # v2.1.1
252
+ with :
253
+ token_format : access_token
254
+ workload_identity_provider : ${{ secrets.GCR_WORKLOAD_IDENTITY }}
255
+ service_account : ${{ secrets.GCR_SERVICE_ACCOUNT }}
256
+ if : github.event.pull_request.head.repo.full_name == github.repository
257
+
258
+ - name : Login to GCR
259
+ uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
260
+ with :
261
+ registry : gcr.io
262
+ username : oauth2accesstoken
263
+ password : ${{ steps.auth.outputs.access_token }}
264
+ if : github.event.pull_request.head.repo.full_name == github.repository
265
+
266
+ - name : Check if base images exist
267
+ id : base_exists
268
+ run : |
269
+ docker manifest inspect gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic-base/oss:${{ needs.checks.outputs.docker_md5 }}-debian
270
+ echo "exists=$?" >> $GITHUB_OUTPUT
271
+ if : github.event.pull_request.head.repo.full_name == github.repository
272
+
273
+ - name : Rebuild base images
274
+ uses : ./.github/workflows/build-base-images.yml
275
+ if : github.event.pull_request.head.repo.full_name == github.repository && steps.base_exists.outputs.exists != 0
276
+
231
277
helm-tests :
232
278
name : Helm Tests
233
279
runs-on : ubuntu-22.04
234
- needs : [checks, binaries]
280
+ needs : [checks, binaries, rebuild-base-images ]
235
281
strategy :
236
282
matrix :
237
283
include :
238
284
- image : debian
239
285
type : oss
240
286
- image : debian-plus
241
287
type : plus
288
+ permissions :
289
+ contents : read
290
+ id-token : write
242
291
steps :
243
292
- name : Checkout Repository
244
293
uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -252,18 +301,36 @@ jobs:
252
301
- name : Docker Buildx
253
302
uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
254
303
304
+ - name : Authenticate to Google Cloud
305
+ id : auth
306
+ uses : google-github-actions/auth@a6e2e39c0a0331da29f7fd2c2a20a427e8d3ad1f # v2.1.1
307
+ with :
308
+ token_format : access_token
309
+ workload_identity_provider : ${{ secrets.GCR_WORKLOAD_IDENTITY }}
310
+ service_account : ${{ secrets.GCR_SERVICE_ACCOUNT }}
311
+ if : github.event.pull_request.head.repo.full_name == github.repository
312
+
313
+ - name : Login to GCR
314
+ uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
315
+ with :
316
+ registry : gcr.io
317
+ username : oauth2accesstoken
318
+ password : ${{ steps.auth.outputs.access_token }}
319
+ if : github.event.pull_request.head.repo.full_name == github.repository
320
+
255
321
- name : Build Docker Image ${{ matrix.image }}
256
322
uses : docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0
257
323
with :
258
324
file : build/Dockerfile
259
325
context : " ."
260
326
cache-from : type=gha,scope=${{ matrix.image }}
261
- target : goreleaser
327
+ target : goreleaser${{ github.event.pull_request.head.repo.full_name == github.repository && '-prebuilt' || '' }}
262
328
tags : ${{ matrix.type }}:${{ github.sha }}
263
329
pull : true
264
330
load : true
265
331
build-args : |
266
332
BUILD_OS=${{ matrix.image }}
333
+ PREBUILT_BASE_IMG=gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/nginx-ic-base/${{ contains(matrix.image, 'plus') && 'plus' || 'oss' }}:${{ needs.checks.outputs.docker_md5 }}-${{ matrix.image }}
267
334
IC_VERSION=CI
268
335
secrets : |
269
336
${{ contains(matrix.type, 'plus') && format('"nginx-repo.crt={0}"', secrets.NGINX_CRT) || '' }}
@@ -316,7 +383,7 @@ jobs:
316
383
setup-matrix :
317
384
name : Setup Matrix for Smoke Tests
318
385
runs-on : ubuntu-22.04
319
- needs : [binaries, checks]
386
+ needs : [binaries, checks, rebuild-base-images ]
320
387
permissions :
321
388
contents : read
322
389
id-token : write
@@ -402,6 +469,7 @@ jobs:
402
469
gcr-service-account-secret : ${{ secrets.GCR_SERVICE_ACCOUNT }}
403
470
rhel-license : ${{ contains(matrix.images.image, 'ubi') && secrets.RHEL_LICENSE || '' }}
404
471
go-md5 : ${{ needs.checks.outputs.go_code_md5 }}
472
+ base-image-md5 : ${{ needs.checks.outputs.docker_md5 }}
405
473
test-image : " gcr.io/f5-gcs-7899-ptg-ingrss-ctlr/dev/test-runner:${{ hashFiles('./tests/requirements.txt') || 'latest' }}"
406
474
407
475
- name : Upload Test Results
@@ -443,6 +511,7 @@ jobs:
443
511
image : ${{ matrix.image }}
444
512
go-md5 : ${{ needs.checks.outputs.go_code_md5 }}
445
513
publish-image : ${{ needs.checks.outputs.publish-images == 'true' }}
514
+ base-image-md5 : ${{ needs.checks.outputs.docker_md5 }}
446
515
permissions :
447
516
contents : read
448
517
actions : read
@@ -470,6 +539,7 @@ jobs:
470
539
image : ${{ matrix.image }}
471
540
target : ${{ matrix.target }}
472
541
go-md5 : ${{ needs.checks.outputs.go_code_md5 }}
542
+ base-image-md5 : ${{ needs.checks.outputs.docker_md5 }}
473
543
release-url : ${{ needs.release-notes.outputs.release-url }}
474
544
publish-image : ${{ needs.checks.outputs.publish-images == 'true' }}
475
545
permissions :
@@ -523,6 +593,7 @@ jobs:
523
593
image : ${{ matrix.image }}
524
594
target : ${{ matrix.target }}
525
595
go-md5 : ${{ needs.checks.outputs.go_code_md5 }}
596
+ base-image-md5 : ${{ needs.checks.outputs.docker_md5 }}
526
597
nap_modules : ${{ matrix.nap_modules }}
527
598
release-url : ${{ needs.release-notes.outputs.release-url }}
528
599
publish-image : ${{ needs.checks.outputs.publish-images == 'true' }}
0 commit comments