From f073e2e13790df8e808ee35b2a184e5a018fea61 Mon Sep 17 00:00:00 2001 From: Leonard Jonathan Oh Date: Fri, 27 Jan 2023 09:14:03 +0000 Subject: [PATCH] Fix (ci): Fix caching for `docker buildx` --- .github/workflows/ci-master-pr.yml | 198 ++++++++++++++---- .../.github/workflows/ci-master-pr.yml.ps1 | 18 +- 2 files changed, 168 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci-master-pr.yml b/.github/workflows/ci-master-pr.yml index c31da81..e2103fc 100644 --- a/.github/workflows/ci-master-pr.yml +++ b/.github/workflows/ci-master-pr.yml @@ -45,8 +45,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -99,7 +100,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -113,7 +114,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -129,7 +131,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} ${{ github.repository }}:latest cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -172,8 +182,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -226,7 +237,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -240,7 +251,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -255,7 +267,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -298,8 +318,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -352,7 +373,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -366,7 +387,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -381,7 +403,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -424,8 +454,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -478,7 +509,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -492,7 +523,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -507,7 +539,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -550,8 +590,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -604,7 +645,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -618,7 +659,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -633,7 +675,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -676,8 +726,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -730,7 +781,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -744,7 +795,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -759,7 +811,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -802,8 +862,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -856,7 +917,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -870,7 +931,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -885,7 +947,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -928,8 +998,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -982,7 +1053,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -996,7 +1067,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -1011,7 +1083,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -1054,8 +1134,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -1108,7 +1189,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -1122,7 +1203,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -1137,7 +1219,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -1180,8 +1270,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -1234,7 +1325,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -1248,7 +1339,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -1263,7 +1355,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images @@ -1306,8 +1406,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -1360,7 +1461,7 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -1374,7 +1475,8 @@ jobs: tags: | ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -1389,7 +1491,15 @@ jobs: ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF }} ${{ github.repository }}:${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images diff --git a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 index c949c3c..6d6cf19 100644 --- a/generate/templates/.github/workflows/ci-master-pr.yml.ps1 +++ b/generate/templates/.github/workflows/ci-master-pr.yml.ps1 @@ -55,8 +55,9 @@ $VARIANTS | % { uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}-${{ github.sha }} restore-keys: | + ${{ runner.os }}-buildx-${{ env.VARIANT_TAG }}- ${{ runner.os }}-buildx- - name: Prepare @@ -112,7 +113,7 @@ $VARIANTS | % { `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF }} `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (master) id: docker_build_master @@ -126,7 +127,8 @@ $VARIANTS | % { tags: | `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF }} `${{ github.repository }}:`${{ env.VARIANT_TAG_WITH_REF_AND_SHA_SHORT }} - cache-to: type=local,dest=/tmp/.buildx-cache + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: Build and push (release) id: docker_build_release @@ -151,7 +153,15 @@ if ( $_['tag_as_latest'] ) { } @' cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache - name: List docker images run: docker images