Add build caching

This commit is contained in:
Jan-Henrik 2023-08-06 14:00:13 +02:00
parent 8aa0ce996a
commit 8f66bcdc8c

View file

@ -28,6 +28,7 @@ jobs:
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
@ -41,6 +42,14 @@ jobs:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-multi-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-multi-buildx
-
name: Build and push by digest
id: build
@ -51,6 +60,11 @@ jobs:
#tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=local,src=/tmp/.buildx-cache
# Note the mode=max here
# More: https://github.com/moby/buildkit#--export-cache-options
# And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
-
name: Export digest
run: |
@ -65,6 +79,10 @@ jobs:
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
merge:
runs-on: ubuntu-latest
needs: