From 5da2ff672cc4b028c90f77d48466290023e0c666 Mon Sep 17 00:00:00 2001 From: Richard Hagen Date: Thu, 12 Dec 2024 14:02:34 +0100 Subject: [PATCH] Build and push image to all registries, use cache (#1249) * echo out dry-run and push versioned pipeline runner * Build and push image to all registries, use cache --- .github/workflows/build-push.yml | 49 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index f0ceafcb5..01bb18a22 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -160,8 +160,7 @@ jobs: - name: Build image tags id: metadata run: | - echo "operator=${{ matrix.target.acr-name }}.azurecr.io/radix-operator:${{ needs.build-operator.outputs.tag }}" >> $GITHUB_OUTPUT - echo "pipeline=${{ matrix.target.acr-name }}.azurecr.io/radix-pipeline:${{ needs.build-pipelinerunner.outputs.tag }}" >> $GITHUB_OUTPUT + echo "operator=${{ matrix.target.acr-name }}.azurecr.io/radix-operator:${{ needs.build-operator.outputs.tag }}" >> $ echo "pipeline_latest=${{ matrix.target.acr-name }}.azurecr.io/radix-pipeline:${{ needs.build-pipelinerunner.outputs.tag_latest }}" >> $GITHUB_OUTPUT - name: ACR Login @@ -169,34 +168,34 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + + - name: Build and push pipeline-runner docker image + uses: docker/build-push-action@v5 with: + context: . + push: true + file: ./pipeline.Dockerfile platforms: | linux/amd64 linux/arm64 + tags: | + ${{ steps.metadata.outputs.operator }} + cache-from: "type=registry,ref=${{ needs.build-operator.outputs.fullname }}-buildcache" + cache-to: "type=registry,ref=${{ needs.build-operator.outputs.fullname }}-buildcache,mode=max" - # This steps reads the original manifest, - # fetches all the digests from the manifest, - # and builds a new for the target repository - - name: Copy Operator image - env: - TARGETREPO: ${{ steps.metadata.outputs.operator }} - SOURCEREPO: ${{ needs.build-operator.outputs.fullname }} - run: | - docker buildx imagetools inspect $SOURCEREPO --raw > manifest.json - tags=$(jq '[.manifests[] | env.SOURCEREPO + "@" + .digest] | join(" ")' -r manifest.json) - echo $tags | xargs docker buildx imagetools create --dry-run --tag $TARGETREPO - echo $tags | xargs docker buildx imagetools create --progress=plain --tag $TARGETREPO - - - name: Copy Pipeline Runner image - env: - TARGETREPO: ${{ steps.metadata.outputs.pipeline }} - TARGETREPO_LATEST: ${{ steps.metadata.outputs.pipeline_latest }} - SOURCEREPO: ${{ needs.build-pipelinerunner.outputs.fullname }} - run: | - docker buildx imagetools inspect $SOURCEREPO --raw > manifest.json - tags=$(jq '[.manifests[] | env.SOURCEREPO + "@" + .digest] | join(" ")' -r manifest.json) - echo $tags | xargs docker buildx imagetools create --dry-run --tag $TARGETREPO --tag $TARGETREPO_LATEST - echo $tags | xargs docker buildx imagetools create --progress=plain --tag $TARGETREPO --tag $TARGETREPO_LATEST + - name: Build and push pipeline-runner docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + file: ./pipeline.Dockerfile + platforms: | + linux/amd64 + linux/arm64 + tags: | + ${{ steps.metadata.outputs.pipeline_latest }} + cache-from: "type=registry,ref=${{ needs.build-pipelinerunner.outputs.fullname }}-buildcache" + cache-to: "type=registry,ref=${{ needs.build-pipelinerunner.outputs.fullname }}-buildcache,mode=max" - name: Revoke GitHub IP on ACR if: ${{ steps.update_firewall.outcome == 'success' && !cancelled()}} # Always run this step even if previous step failed