Skip to content

Commit 8525e8a

Browse files
committed
Skip empty matrix builds
1 parent 8b7f4ee commit 8525e8a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

.github/workflows/build-docker-artifacts.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ jobs:
312312
test-images:
313313
name: Test images of flavor ${{ matrix.flavor.id || 'default' }}
314314
needs: [get-flavors, build-flavors]
315+
# Skip in case we would have an empty matrix. Note that in this case it also skips all downstream jobs...
316+
if: ${{ toJSON(fromJson(needs.get-flavors.outputs.result).flavorsToTest) != '[]' }}
315317
strategy:
316318
fail-fast: false
317319
matrix:
@@ -381,6 +383,9 @@ jobs:
381383
retag-images:
382384
name: Retag images of flavor ${{ matrix.flavor.id || 'default' }}
383385
needs: [get-flavors, test-images]
386+
# Skip in case we would have an empty matrix. Note that in this case it also skips all downstream jobs...
387+
# We need the always() && !cancelled() && !failure() because the test-images may have been skipped (which is fine). See https://github.com/actions/runner/issues/491#issuecomment-1507495166
388+
if: ${{ always() && !cancelled() && !failure() && toJSON(fromJson(needs.get-flavors.outputs.result).flavorsToRetag) != '[]' }}
384389
strategy:
385390
fail-fast: false
386391
matrix:
@@ -439,9 +444,9 @@ jobs:
439444

440445
push-to-repositories:
441446
name: Push images to push targets
447+
needs: [retag-images, get-flavors]
442448
# if? When should we do this? Always? Only for certain branches? If so, how should we define that, in the config.json?
443449
if: ${{ fromJson(needs.get-flavors.outputs.result).skip_push != true && fromJson(needs.get-flavors.outputs.result).push_to != '' }}
444-
needs: [retag-images, get-flavors]
445450
uses: datavisyn/github-workflows/.github/workflows/build-docker-artifacts-trigger-push.yml@main
446451
secrets: inherit
447452
with:

0 commit comments

Comments
 (0)