From bdfb0a4127d3309d83e035f664170fda6c613738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Wed, 23 Oct 2024 15:31:04 +0800 Subject: [PATCH] ci: update ci --- .github/workflows/ci.yml | 49 +++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3748e0..593d133 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,25 +28,58 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and export to Docker + # We have to build each platform separately because when using multi-arch + # builds, only one platform is being loaded into the cache. This would + # prevent us from testing the other platforms. + - name: Build Docker image (linux/amd64) uses: docker/build-push-action@v6 with: + platforms: linux/amd64 context: . - platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: false load: true - tags: ${{ env.TEST_TAG }} + tags: ${{ env.TEST_TAG }}-linux-amd64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new - - name: Test - run: | - docker run --rm ${{ env.TEST_TAG }} -h - - - name: Build and push + - name: Build Docker image (linux/arm64) uses: docker/build-push-action@v6 with: + platforms: linux/arm64 context: . + push: false + load: true + tags: ${{ env.TEST_TAG }}-linux-arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - name: Build Docker image (linux/arm/v7) + uses: docker/build-push-action@v6 + with: + platforms: linux/arm/v7 + context: . + push: false + load: true + tags: ${{ env.TEST_TAG }}-linux-arm-v7 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # We test all the images on amd64 host here. This uses QEMU to emulate + # the other platforms. + - run: docker run --rm ${{ TEST_TAG }}-linux-amd64 --version + - run: docker run --rm ${{ TEST_TAG }}-linux-arm-v7 --version + - run: docker run --rm ${{ TEST_TAG }}-linux-arm64-v8 --version + + # This will only push the previously built images. + - name: Publish to Docker Hub + uses: docker/build-push-action@v6 + with: platforms: linux/amd64,linux/arm64,linux/arm/v7 + context: . push: true tags: ${{ env.TEST_TAG }} + cache-from: type=local,src=/tmp/.buildx-cache-new + cache-to: type=local,dest=/tmp/.buildx-cache-new - name: Docker Hub Description uses: peter-evans/dockerhub-description@v4