diff --git a/content/build/ci/github-actions/multi-platform.md b/content/build/ci/github-actions/multi-platform.md index 0b9f2a8e17..8c53a91e9d 100644 --- a/content/build/ci/github-actions/multi-platform.md +++ b/content/build/ci/github-actions/multi-platform.md @@ -85,23 +85,34 @@ jobs: - linux/arm/v7 - linux/arm64 steps: - - name: Checkout + - + name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - + name: Checkout uses: actions/checkout@v4 - - name: Docker meta + - + name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} - - name: Set up QEMU + - + name: Set up QEMU uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to Docker Hub + - + name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push by digest + - + name: Build and push by digest id: build uses: docker/build-push-action@v5 with: @@ -109,15 +120,17 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - - name: Export digest + - + name: Export digest run: | mkdir -p /tmp/digests digest="${{ steps.build.outputs.digest }}" touch "/tmp/digests/${digest#sha256:}" - - name: Upload digest - uses: actions/upload-artifact@v3 + - + name: Upload digest + uses: actions/upload-artifact@v4 with: - name: digests + name: digests-${{ env.PLATFORM_PAIR }} path: /tmp/digests/* if-no-files-found: error retention-days: 1 @@ -127,29 +140,36 @@ jobs: needs: - build steps: - - name: Download digests - uses: actions/download-artifact@v3 + - + name: Download digests + uses: actions/download-artifact@v4 with: - name: digests path: /tmp/digests - - name: Set up Docker Buildx + pattern: digests-* + merge-multiple: true + - + name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Docker meta + - + name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} - - name: Login to Docker Hub + - + name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Create manifest list and push + - + name: Create manifest list and push working-directory: /tmp/digests run: | docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) - - name: Inspect image + - + name: Inspect image run: | docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} ``` @@ -228,19 +248,6 @@ jobs: name: Show matrix run: | echo ${{ steps.platforms.outputs.matrix }} - - build: - runs-on: ubuntu-latest - needs: - - prepare - strategy: - fail-fast: false - matrix: - platform: ${{ fromJson(needs.prepare.outputs.matrix) }} - steps: - - - name: Checkout - uses: actions/checkout@v4 - name: Docker meta id: meta @@ -253,12 +260,36 @@ jobs: mv "${{ steps.meta.outputs.bake-file }}" "/tmp/bake-meta.json" - name: Upload meta bake definition - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: bake-meta path: /tmp/bake-meta.json if-no-files-found: error retention-days: 1 + + build: + runs-on: ubuntu-latest + needs: + - prepare + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(needs.prepare.outputs.matrix) }} + steps: + - + name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - + name: Checkout + uses: actions/checkout@v4 + - + name: Download meta bake definition + uses: actions/download-artifact@v4 + with: + name: bake-meta + path: /tmp - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -292,9 +323,9 @@ jobs: touch "/tmp/digests/${digest#sha256:}" - name: Upload digest - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: digests + name: digests-${{ env.PLATFORM_PAIR }} path: /tmp/digests/* if-no-files-found: error retention-days: 1 @@ -312,10 +343,11 @@ jobs: path: /tmp - name: Download digests - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: digests path: /tmp/digests + pattern: digests-* + merge-multiple: true - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3