Skip to content

Commit ccb9a39

Browse files
authored
Add caching
1 parent 19dc949 commit ccb9a39

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

.github/workflows/docker-publish.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ jobs:
4141
# https://github.com/sigstore/cosign-installer
4242
- name: Install cosign
4343
if: github.event_name != 'pull_request'
44-
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
44+
uses: sigstore/cosign-installer@v2
4545
with:
4646
cosign-release: 'v1.4.0'
4747

4848

4949
# Workaround: https://github.com/docker/build-push-action/issues/461
5050
- name: Setup Docker buildx
51-
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
51+
uses: docker/setup-buildx-action@v1
5252

5353
# Login against a Docker registry except on PR
5454
# https://github.com/docker/login-action
@@ -64,20 +64,38 @@ jobs:
6464
# https://github.com/docker/metadata-action
6565
- name: Extract Docker metadata
6666
id: meta
67-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
67+
uses: docker/metadata-action@v3
6868
with:
6969
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
7070

71+
- name: Cache Docker layers
72+
uses: actions/cache@v3
73+
with:
74+
path: /tmp/.buildx-cache
75+
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
76+
restore-keys: |
77+
${{ runner.os }}-single-buildx
78+
7179
# Build and push Docker image with Buildx (don't push on PR)
7280
# https://github.com/docker/build-push-action
7381
- name: Build and push Docker image
7482
id: build-and-push
75-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
83+
uses: docker/build-push-action@v2
7684
with:
7785
context: .
7886
push: ${{ github.event_name != 'pull_request' }}
7987
tags: ${{ steps.meta.outputs.tags }}
8088
labels: ${{ steps.meta.outputs.labels }}
89+
cache-from: type=local,src=/tmp/.buildx-cache
90+
cache-to: type=local,dest=/tmp/.buildx-cache-new
91+
92+
# Temp fix
93+
# https://github.com/docker/build-push-action/issues/252
94+
# https://github.com/moby/buildkit/issues/1896
95+
- name: Move cache
96+
run:
97+
rm -rf /tmp/.buildx-cache
98+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
8199

82100
# Sign the resulting Docker image digest except on PRs.
83101
# This will only write to the public Rekor transparency log when the Docker

0 commit comments

Comments
 (0)