Skip to content

Commit 5dbc258

Browse files
committed
so better
1 parent 0e29c86 commit 5dbc258

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

.github/actions/prepare-builder/action.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -46,7 +50,7 @@ runs:
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 }}"
@@ -62,6 +66,6 @@ runs:
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

Comments
 (0)