From b90b6d0b255c2ecdab8782151d714d46ae1d961b Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Thu, 7 Sep 2023 09:43:38 +0200 Subject: [PATCH] :green_heart: Fix docker multi arch overwrite issue (#779) Closes #776 --- .github/workflows/publish_docker_images.yml | 76 ++++++++++++++++++--- 1 file changed, 66 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish_docker_images.yml b/.github/workflows/publish_docker_images.yml index 4c289c3bd..699c0906e 100644 --- a/.github/workflows/publish_docker_images.yml +++ b/.github/workflows/publish_docker_images.yml @@ -33,8 +33,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - if: github.event_name != 'pull_request' - name: Log in to Docker Hub + - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -44,18 +43,29 @@ jobs: id: docker_build uses: docker/build-push-action@v4 with: - push: ${{ github.event_name != 'pull_request' }} context: . tags: ${{ steps.image-meta.outputs.tags }} labels: ${{ steps.image-meta.outputs.labels }} + outputs: type=image,name=baptistearno/typebot-${{ matrix.app }},push-by-digest=true,name-canonical=true,push=true platforms: linux/amd64 cache-from: type=gha cache-to: type=gha,mode=max build-args: | SCOPE=${{ matrix.app }} - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.docker_build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v3 + with: + name: digests + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 build-arm: env: @@ -82,8 +92,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - if: github.event_name != 'pull_request' - name: Log in to Docker Hub + - name: Log in to Docker Hub uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -93,15 +102,62 @@ jobs: id: docker_build uses: docker/build-push-action@v4 with: - push: ${{ github.event_name != 'pull_request' }} context: . tags: ${{ steps.image-meta.outputs.tags }} labels: ${{ steps.image-meta.outputs.labels }} + outputs: type=image,name=baptistearno/typebot-${{ matrix.app }},push-by-digest=true,name-canonical=true,push=true platforms: linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max build-args: | SCOPE=${{ matrix.app }} - - name: Image digest - run: echo ${{ steps.docker_build.outputs.digest }} + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.docker_build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v3 + with: + name: digests + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge: + if: ${{ github.event_name != 'pull_request' }} + runs-on: ubuntu-latest + needs: + - build-amd + - build-arm + strategy: + matrix: + app: ['builder', 'viewer'] + steps: + - name: Download digests + uses: actions/download-artifact@v3 + with: + name: digests + path: /tmp/digests + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: baptistearno/typebot-${{ matrix.app }} + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - 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 'baptistearno/typebot-${{ matrix.app }}@sha256:%s ' *) + - name: Inspect image + run: | + docker buildx imagetools inspect baptistearno/typebot-${{ matrix.app }}:${{ steps.meta.outputs.version }}