From ece0fbd1312ed08c517627905c8ef9427abbec96 Mon Sep 17 00:00:00 2001 From: Donkie Date: Wed, 12 Jul 2023 15:33:50 +0200 Subject: [PATCH] New attempt at registry cache --- .github/workflows/ci.yml | 54 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 444217e..0015bc1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,14 +46,21 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Log in to the Github Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Spoolman uses: docker/build-push-action@v4 with: context: . tags: ${{ env.IMAGE_NAME }}:test outputs: type=docker,dest=/tmp/spoolman.tar - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64 + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max - name: Upload artifact uses: actions/upload-artifact@v3 @@ -72,14 +79,21 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Log in to the Github Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build Spoolman Tester uses: docker/build-push-action@v4 with: context: ./tests_integration tags: ${{ env.IMAGE_NAME }}-tester:latest outputs: type=docker,dest=/tmp/spoolman-tester.tar - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-tester,mode=max - name: Upload artifact uses: actions/upload-artifact@v3 @@ -160,5 +174,33 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64 + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64 + type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7 + + # Workaround for multiple cache-to's not really working + # See https://github.com/docker/buildx/discussions/1382 + - name: Cache amd64 build + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64 + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64 + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max + + - name: Cache arm64 build + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/arm64 + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64 + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max + + - name: Cache armv7 build + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/arm/v7 + cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7 + cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-armv7,mode=max