From d89bb8a8689d955bc73799dff554b86d920ce532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petri=20=C3=84mm=C3=A4l=C3=A4?= Date: Mon, 9 Mar 2026 10:57:19 +0200 Subject: [PATCH] Add scope to cache --- .github/workflows/digabi-docker-build.yml | 28 +++++++---------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/digabi-docker-build.yml b/.github/workflows/digabi-docker-build.yml index 214abfd..2b1f77c 100644 --- a/.github/workflows/digabi-docker-build.yml +++ b/.github/workflows/digabi-docker-build.yml @@ -82,21 +82,6 @@ jobs: uses: docker/setup-buildx-action@v3 - id: docker-tags uses: digabi/workflows-common/actions/get-image-tags@main - - name: Build and push to Amazon ECR - if: ${{ !startsWith(steps.docker-tags.outputs.image_tag, 'dependabot') }} - uses: docker/build-push-action@v5 - with: - push: true - file: ${{ inputs.file }} - context: ${{ inputs.context }} - tags: ${{ steps.login-ecr.outputs.registry }}/${{ inputs.image-name }}:${{ steps.docker-tags.outputs.image_tag }} - provenance: false - target: ${{ inputs.docker-target }} - platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max - secrets: | - npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - name: Log in to the GitHub Container registry if: ${{ inputs.tag-latest}} uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 @@ -104,19 +89,22 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push latest tag to GitHub Container Registry - if: ${{ inputs.tag-latest }} + - name: Build and push image + if: ${{ !startsWith(steps.docker-tags.outputs.image_tag, 'dependabot') }} uses: docker/build-push-action@v5 with: push: true file: ${{ inputs.file }} context: ${{ inputs.context }} - tags: ghcr.io/digabi/${{ inputs.image-name }}:${{ steps.docker-tags.outputs.image_tag_latest }} provenance: false target: ${{ inputs.docker-target }} platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max + pull: true + tags: | + ${{ steps.login-ecr.outputs.registry }}/${{ inputs.image-name }}:${{ steps.docker-tags.outputs.image_tag }} + ${{ inputs.tag-latest && format('ghcr.io/digabi/{0}:{1}', inputs.image-name, steps.docker-tags.outputs.image_tag_latest) || '' }} + cache-from: type=gha,scope=${{ github.repository }}-${{ inputs.image-name }} + cache-to: type=gha,scope=${{ github.repository }}-${{ inputs.image-name }},mode=max secrets: | npmrc=//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} - name: Delete orphaned images from Github Container Registry