Skip to content

Commit d2dadb3

Browse files
authored
use Docker registry as cache (#286)
1 parent 23f6b03 commit d2dadb3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/build-docker.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757
[registry."docker.io"]
5858
mirrors = ["dockerhub-proxy.teonite.net"]
5959
60+
- name: Sanitize branch name
61+
run: echo "SAFE_REF=${GITHUB_REF_NAME//\//-}" >> $GITHUB_ENV
62+
6063
- name: Build container
6164
uses: docker/build-push-action@v7
6265
with:
@@ -65,8 +68,10 @@ jobs:
6568
provenance: false
6669
push: true
6770
tags: "${{ env.GHCR_REPO }}:${{ github.sha }}-${{ matrix.tag }}"
68-
cache-from: type=gha
69-
cache-to: type=gha,mode=max
71+
cache-from: |
72+
type=registry,ref=${{ env.GHCR_REPO }}:cache-${{ matrix.tag }}
73+
type=registry,ref=${{ env.GHCR_REPO }}:cache-${{ matrix.tag }}-${{ env.SAFE_REF }}
74+
cache-to: type=registry,mode=max,ref=${{ env.GHCR_REPO }}:cache-${{ matrix.tag }}-${{ env.SAFE_REF }}
7075

7176
- name: Scan image with Trivy
7277
uses: aquasecurity/trivy-action@v0.36.0

0 commit comments

Comments
 (0)