Skip to content

Commit 96a8bb0

Browse files
committed
speedup cache warmup if cache exists
1 parent 4397853 commit 96a8bb0

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/_shared-prepare-docker-cache.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,28 @@ jobs:
2323
echo "kurtosis_version=$kurtosis_version" >> $GITHUB_OUTPUT
2424
2525
echo "Kurtosis version: $kurtosis_version"
26+
- name: Check if cache key exists
27+
id: check_cache
28+
env:
29+
GH_TOKEN: ${{ github.token }}
30+
run: |
31+
KEY="kurtosis-docker-${{ runner.os }}-${{ steps.kurtosis_version.outputs.kurtosis_version }}"
32+
CACHE_HIT=$(gh cache list --repo ${{ github.repository }} --json "key" --key "$KEY" | jq -c ".[]" | wc -l)
33+
if [ $CACHE_HIT -gt 0 ]; then
34+
echo "exists=true" >> $GITHUB_OUTPUT
35+
else
36+
echo "exists=false" >> $GITHUB_OUTPUT
37+
fi
38+
2639
- name: Cache Docker images.
2740
id: cache
41+
if: ${{ steps.check_cache.outputs.exists == 'false' }}
2842
uses: ScribeMD/docker-cache@0.5.0
2943
with:
3044
key: kurtosis-docker-${{ runner.os }}-${{ steps.kurtosis_version.outputs.kurtosis_version }}
3145

3246
- name: "Generate dummy kurtosis config"
47+
if: ${{ steps.check_cache.outputs.exists == 'false' }}
3348
shell: bash
3449
run: |
3550
mkdir -p ./temp

0 commit comments

Comments
 (0)