Skip to content

Commit 64e01ab

Browse files
committed
CI: Use GHCR for caching directly
1 parent 890072d commit 64e01ab

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

.github/workflows/docker.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Docker build
33
on:
44
workflow_dispatch:
55
push:
6-
branches: [ "master", "maint/*", "ci/gha-docker-build" ]
6+
branches: [ "master", "main", "maint/*", "ci/gha-docker-build" ]
77
tags: "*"
88
pull_request:
9-
branches: [ "master" ]
9+
branches: [ "master", "main", "maint/*" ]
1010

1111
env:
1212
REGISTRY: ghcr.io
@@ -40,12 +40,18 @@ jobs:
4040
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
4141

4242
- name: Build and push Docker image
43-
id: build-and-push
4443
uses: docker/build-push-action@v4
4544
with:
4645
context: .
4746
push: ${{ github.event_name != 'pull_request' }}
4847
tags: ${{ steps.meta.outputs.tags }}
4948
labels: ${{ steps.meta.outputs.labels }}
50-
cache-from: type=registry,ref=${{ fromJSON(steps.meta.outputs.json).tags[0] }}
51-
cache-to: inline
49+
cache-from: |
50+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache
51+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ env.TARGET_BRANCH }}
52+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }}
53+
cache-to: |
54+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache,mode=max
55+
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:cache-${{ github.ref_name }},mode=max
56+
env:
57+
TARGET_BRANCH: ${{ github.base_ref || github.ref_name }}

0 commit comments

Comments
 (0)