@@ -25,18 +25,22 @@ runs:
2525 id : image-name
2626 shell : bash
2727 run : |
28- IMG=$(yq -r '.services."${{ inputs.service }}".image' docker-compose.yml)
29- echo "image=${IMG}" >> $GITHUB_OUTPUT
28+ IMAGE=$(yq -r '.services."${{ inputs.service }}".image' docker-compose.yml)
29+ BASE_IMAGE="${IMAGE%%:*}"
30+ HASH=$(sha256sum Dockerfile | cut -d " " -f1)
31+ echo "image=${IMAGE}" >> $GITHUB_OUTPUT
3032
31- CACHE_TAG="ghcr.io/${{ github.repository_owner }}/cache-${IMG}"
32- echo "cache=${CACHE_TAG}" >> $GITHUB_OUTPUT
33+ CACHE_IMAGE="ghcr.io/${{ github.repository_owner }}/cache-${BASE_IMAGE}:${HASH}"
34+
35+ echo "hash=${HASH}" >> $GITHUB_OUTPUT
36+ echo "cache-image=${CACHE_IMAGE}" >> $GITHUB_OUTPUT
3337
3438 - name : Try pulling cache from GHCR
3539 id : pull-cache
3640 shell : bash
3741 run : |
38- echo "Trying to pull cache image: ${{ steps.image-name.outputs.cache }}"
39- if podman pull "${{ steps.image-name.outputs.cache }}"; then
42+ echo "Trying to pull cache image: ${{ steps.image-name.outputs.cache-image }}"
43+ if podman pull "${{ steps.image-name.outputs.cache-image }}"; then
4044 echo "cache-hit=true" >> $GITHUB_OUTPUT
4145 else
4246 echo "cache-hit=false" >> $GITHUB_OUTPUT
4650 if : steps.pull-cache.outputs.cache-hit == 'true'
4751 shell : bash
4852 run : |
49- podman tag "${{ steps.image-name.outputs.cache }}" \
53+ podman tag "${{ steps.image-name.outputs.cache-image }}" \
5054 "${{ steps.image-name.outputs.image }}"
5155
5256 echo "Loaded cached image: ${{ steps.image-name.outputs.image }}"
6266 shell : bash
6367 run : |
6468 podman tag "${{ steps.image-name.outputs.image }}" \
65- "${{ steps.image-name.outputs.cache }}"
69+ "${{ steps.image-name.outputs.cache-image }}"
6670
67- podman push "${{ steps.image-name.outputs.cache }}"
71+ podman push "${{ steps.image-name.outputs.cache-image }}"
0 commit comments