Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions content/manuals/build/ci/github-actions/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5

Comment on lines +222 to +224
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is checkout needed here? By default build-push action should build with git context.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for the build-cache-dance action. It needs to read the dockerfile to parse it and extract the paths of the cache mounts used in the dockerfile. Without checkout, I get this error:

No cache map provided. Trying to parse the Dockerfile to find the cache mount instructions...
Error: Failed to parse cache map. Expected JSON, got:
{}
Error: ENOENT: no such file or directory, open 'build/package/Dockerfile'

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -230,6 +233,7 @@ jobs:

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: setup-buildx

- name: Docker meta
id: meta
Expand All @@ -248,10 +252,13 @@ jobs:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}

- name: Inject go-build-cache
uses: reproducible-containers/buildkit-cache-dance@4b2444fec0c0fb9dbf175a96c094720a692ef810 # v2.1.4
- name: Restore Docker cache mounts
uses: reproducible-containers/buildkit-cache-dance@5b81f4d29dc8397a7d341dba3aeecc7ec54d6361 # v3.3.0
with:
cache-source: go-build-cache
builder: ${{ steps.setup-buildx.outputs.name }}
cache-dir: cache-mount
dockerfile: build/package/Dockerfile
skip-extraction: ${{ steps.cache.outputs.cache-hit }}

- name: Build and push
uses: docker/build-push-action@v6
Expand All @@ -263,6 +270,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64

```

For more information about this workaround, refer to the
Expand Down