Skip to content

Commit 2d0740f

Browse files
committed
ci: create matrix for building frontend image
Signed-off-by: CrazyMax <[email protected]>
1 parent b666117 commit 2d0740f

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ jobs:
444444
if: github.event_name != 'schedule'
445445
outputs:
446446
typ: ${{ steps.prep.outputs.typ }}
447-
tag: ${{ steps.prep.outputs.tag }}
448447
push: ${{ steps.prep.outputs.push }}
448+
matrix: ${{ steps.prep.outputs.matrix }}
449449
steps:
450450
-
451451
name: Prepare
@@ -462,14 +462,30 @@ jobs:
462462
PUSH=push
463463
fi
464464
echo "typ=${TYP}" >>${GITHUB_OUTPUT}
465-
echo "tag=${TAG}" >>${GITHUB_OUTPUT}
466465
echo "push=${PUSH}" >>${GITHUB_OUTPUT}
466+
if [ "${TYP}" = "master" ]; then
467+
echo "matrix=$(jq -cn --arg tag "$TAG" '[$tag, "labs"]')" >>${GITHUB_OUTPUT}
468+
else
469+
echo "matrix=$(jq -cn --arg tag "$TAG" '[$tag]')" >>${GITHUB_OUTPUT}
470+
fi
467471
468472
frontend-image:
469473
runs-on: ubuntu-20.04
470474
if: github.event_name != 'schedule'
471475
needs: [frontend-base, test]
476+
strategy:
477+
fail-fast: false
478+
matrix:
479+
tag: ${{ fromJson(needs.frontend-base.outputs.matrix) }}
472480
steps:
481+
-
482+
name: Prepare
483+
run: |
484+
if [ "${{ matrix.tag }}" = "labs" ]; then
485+
echo "CACHE_SCOPE=frontend-labs" >>${GITHUB_ENV}
486+
else
487+
echo "CACHE_SCOPE=frontend-mainline" >>${GITHUB_ENV}
488+
fi
473489
-
474490
name: Checkout
475491
uses: actions/checkout@v3
@@ -494,18 +510,10 @@ jobs:
494510
username: ${{ secrets.DOCKERHUB_USERNAME }}
495511
password: ${{ secrets.DOCKERHUB_TOKEN }}
496512
-
497-
name: Build ${{ needs.frontend-base.outputs.typ }}/${{ needs.frontend-base.outputs.tag }}
498-
run: |
499-
./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" "${{ needs.frontend-base.outputs.tag }}" "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}"
500-
env:
501-
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
502-
CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
503-
CACHE_TO: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
504-
-
505-
name: Build ${{ needs.frontend-base.outputs.typ }}/labs
506-
if: needs.frontend-base.outputs.typ == 'master'
513+
name: Build
507514
run: |
508-
./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" labs "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}"
515+
./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" "${{ matrix.tag }}" "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}"
509516
env:
510517
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
511-
CACHE_FROM: type=gha,scope=frontend-${{ needs.frontend-base.outputs.typ }}
518+
CACHE_FROM: type=gha,scope=${{ env.CACHE_SCOPE }}
519+
CACHE_TO: type=gha,scope=${{ env.CACHE_SCOPE }}

0 commit comments

Comments
 (0)