Skip to content

Commit 273bcb0

Browse files
committed
fix: add dummy command to docker create for scratch images
Newer Docker versions require a command argument for `docker create` on FROM scratch images. Without it, create fails silently (stderr redirected) and the subsequent docker cp exits 1, breaking the cache-restore step. Also handle docker create/cp/rm failures gracefully — a broken cache should degrade to cold start, not fail the pipeline.
1 parent 5b177e0 commit 273bcb0

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,14 @@ runs:
146146
exit 0
147147
fi
148148
149-
container_id=$(docker create "$manifest_image" 2>/dev/null)
150-
docker cp "$container_id:/manifest.json" .harmont-cache/manifest.json 2>/dev/null
151-
docker rm "$container_id" > /dev/null 2>&1
149+
container_id=$(docker create "$manifest_image" _ 2>/dev/null) || {
150+
echo "Failed to create container from manifest image, cold start"
151+
echo "restored=false" >> "$GITHUB_OUTPUT"
152+
echo "::endgroup::"
153+
exit 0
154+
}
155+
docker cp "$container_id:/manifest.json" .harmont-cache/manifest.json 2>/dev/null || true
156+
docker rm "$container_id" > /dev/null 2>&1 || true
152157
echo "::endgroup::"
153158
154159
if [ ! -f .harmont-cache/manifest.json ]; then

cache-restore/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,14 @@ runs:
6666
fi
6767
6868
# Extract manifest.json from the image
69-
container_id=$(docker create "$manifest_image" 2>/dev/null)
70-
docker cp "$container_id:/manifest.json" .harmont-cache/manifest.json 2>/dev/null
71-
docker rm "$container_id" > /dev/null 2>&1
69+
container_id=$(docker create "$manifest_image" _ 2>/dev/null) || {
70+
echo "Failed to create container from manifest image, cold start"
71+
echo "restored=false" >> "$GITHUB_OUTPUT"
72+
echo "::endgroup::"
73+
exit 0
74+
}
75+
docker cp "$container_id:/manifest.json" .harmont-cache/manifest.json 2>/dev/null || true
76+
docker rm "$container_id" > /dev/null 2>&1 || true
7277
echo "::endgroup::"
7378
7479
if [ ! -f .harmont-cache/manifest.json ]; then

0 commit comments

Comments
 (0)