@@ -15,33 +15,47 @@ runs:
1515 run : |
1616 set -euo pipefail
1717 cache_dir="/tmp/ether-scan-image-cache"
18- sanitized_image="${{ inputs.image }}"
18+ image="${{ inputs.image }}"
19+ tag="${image##*:}"
20+ use_cache="false"
21+ if [[ "$tag" =~ [0-9] ]]; then
22+ use_cache="true"
23+ fi
24+
25+ sanitized_image="$image"
1926 sanitized_image="${sanitized_image//\//-}"
2027 sanitized_image="${sanitized_image//:/-}"
2128 echo "file=${cache_dir}/${sanitized_image}.tar" >> "$GITHUB_OUTPUT"
2229 echo "key=docker-image-${{ runner.os }}-${sanitized_image}" >> "$GITHUB_OUTPUT"
30+ echo "use-cache=${use_cache}" >> "$GITHUB_OUTPUT"
2331
2432 - name : Check cache for Docker image
33+ if : steps.cache-file.outputs.use-cache == 'true'
2534 id : docker-image-cache
2635 uses : actions/cache@v5
2736 with :
2837 path : /tmp/ether-scan-image-cache
2938 key : ${{ steps.cache-file.outputs.key }}
3039
3140 - name : Load cached Docker image
32- if : steps.docker-image-cache.outputs.cache-hit == 'true'
41+ if : steps.cache-file.outputs.use-cache == 'true' && steps. docker-image-cache.outputs.cache-hit == 'true'
3342 shell : bash
3443 run : docker image load --input "${{ steps.cache-file.outputs.file }}"
3544
3645 - name : Pull and save Docker image on cache miss
37- if : steps.docker-image-cache.outputs.cache-hit != 'true'
46+ if : steps.cache-file.outputs.use-cache == 'true' && steps. docker-image-cache.outputs.cache-hit != 'true'
3847 shell : bash
3948 run : |
4049 set -euo pipefail
4150 mkdir -p /tmp/ether-scan-image-cache
4251 docker pull "${{ inputs.image }}"
4352 docker image save "${{ inputs.image }}" --output "${{ steps.cache-file.outputs.file }}"
4453
54+ - name : Pull Docker image without cache
55+ if : steps.cache-file.outputs.use-cache != 'true'
56+ shell : bash
57+ run : docker pull "${{ inputs.image }}"
58+
4559 - name : Cache Composer packages
4660 uses : actions/cache@v5
4761 with :
0 commit comments