Skip to content

Commit 5fa1542

Browse files
committed
Add warm layer cache step and use for cacheFrom
1 parent 6bd91a4 commit 5fa1542

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,23 @@ jobs:
3333
id: image_name
3434
run: echo "value=ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')/devcontainer" >> $GITHUB_OUTPUT
3535

36+
- name: Warm layer cache (skip on first run when image does not exist yet)
37+
id: cache
38+
run: |
39+
IMAGE="${{ steps.image_name.outputs.value }}"
40+
if docker pull "${IMAGE}:latest" 2>/dev/null; then
41+
echo "from=${IMAGE}" >> $GITHUB_OUTPUT
42+
else
43+
echo "from=" >> $GITHUB_OUTPUT
44+
fi
45+
3646
- name: Build Dev Container and run tests
3747
uses: devcontainers/ci@v0.3
3848
with:
3949
imageName: ${{ steps.image_name.outputs.value }}
40-
# Pull the previous image as a layer cache — unchanged layers are reused,
41-
# dramatically reducing build time on subsequent runs.
42-
cacheFrom: ${{ steps.image_name.outputs.value }}
50+
# Non-empty only after the first successful push; BuildKit skips --cache-from
51+
# when this is blank, avoiding the "not found" hard error introduced in BuildKit 0.12.
52+
cacheFrom: ${{ steps.cache.outputs.from }}
4353
# This is the same command developers run locally. No translation required.
4454
runCmd: npm test
4555

0 commit comments

Comments
 (0)