Skip to content

Commit a11984e

Browse files
committed
Add caching for pulled Docker images
1 parent e16332a commit a11984e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/run.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ jobs:
2929
run: |
3030
git config user.name github-actions[bot]
3131
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
32+
- name: Cache Docker images
33+
uses: actions/cache@v4
34+
with:
35+
path: /tmp/docker-cache
36+
key: ${{ runner.os }}-docker-images
37+
restore-keys: |
38+
${{ runner.os }}-docker-
39+
- name: Load Docker cache
40+
run: |
41+
if [ -f /tmp/docker-cache/docker-cache.tar ]; then
42+
echo "Loading Docker images from cache..."
43+
docker load < /tmp/docker-cache/docker-cache.tar
44+
fi
3245
- name: Setup uv
3346
uses: astral-sh/setup-uv@v5
3447
- name: Install Calkit
@@ -47,6 +60,16 @@ jobs:
4760
- run: calkit dvc pull
4861
continue-on-error: true
4962
- run: calkit run
63+
- name: Save Docker cache
64+
run: |
65+
mkdir -p /tmp/docker-cache
66+
# Save all non-base images
67+
docker images --format "{{.Repository}}:{{.Tag}}" | grep -v "<none>" | grep -v "ubuntu\|alpine\|debian" > /tmp/docker-images.txt || true
68+
if [ -s /tmp/docker-images.txt ]; then
69+
echo "Saving Docker images to cache..."
70+
docker save $(cat /tmp/docker-images.txt) > /tmp/docker-cache/docker-cache.tar
71+
fi
72+
if: always()
5073
# If running on a PR, push to that branch, else push to main
5174
- run: calkit save -am "Run pipeline"
5275
env:

0 commit comments

Comments
 (0)