diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 34c4b7f..2e5bddd 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -53,6 +53,17 @@ jobs: - name: Setup Docker buildx uses: docker/setup-buildx-action@v3.10.0 + - name: Extract Docker cache metadata + id: meta-cache + uses: docker/metadata-action@v5.7.0 + with: + # list of Docker images to use as base name for tags + # //- + images: | + ${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache + tags: | + type=raw,value=tests + # Build but don't push Docker image with Buildx # https://github.com/docker/build-push-action - name: Build test image @@ -63,8 +74,8 @@ jobs: load: true target: dev tags: ${{ env.TEST_TAG }} - cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache:tests - cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache:tests,mode=max + cache-from: type=registry,ref=${{ steps.meta-cache.outputs.tags }} + cache-to: type=registry,ref=${{ steps.meta-cache.outputs.tags }},mode=max # This is a barrier check to make sure we push a functional # docker image, we can avoid linting @@ -137,6 +148,16 @@ jobs: images: | ${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-${{ matrix.docker_target }} + - name: Extract Docker cache metadata + id: meta-cache + uses: docker/metadata-action@v5.7.0 + with: + # list of Docker images to use as base name for tags + # //- + images: | + ${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache + tags: | + type=raw,value=buildcache-${{ matrix.docker_target }}-${{ env.PLATFORM_PAIR }} # This build an image WITHOUT tags and outputs the digests, so that we can aggragate them later - name: Build and push production image @@ -149,8 +170,8 @@ jobs: outputs: type=image,push-by-digest=true,name-canonical=true,push=true tags: ${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-${{ matrix.docker_target }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache:buildcache-${{ matrix.docker_target }}-${{ env.PLATFORM_PAIR }} - cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REGISTRY_PATH }}/${{ env.IMAGE_NAME }}-cache:buildcache-${{ matrix.docker_target }}-${{ env.PLATFORM_PAIR }},mode=max + cache-from: type=registry,ref=${{ steps.meta-cache.outputs.tags }} + cache-to: type=registry,ref=${{ steps.meta-cache.outputs.tags }},mode=max - name: Export digest run: |