33
33
- name : Get Latest Idris Commit SHA
34
34
id : get-sha
35
35
uses : ./.github/actions/get-idris-sha
36
+
37
+ # if platforms is not equal to linux/amd64, do not cache-to (output empty string)
38
+ # See: https://github.com/joshuanianji/idris-2-docker/pull/71
39
+ - name : Calculate cache-to
40
+ id : calculate-cache-to
41
+ run : |
42
+ if [ "${{ inputs.platforms }}" == "linux/amd64" ]; then
43
+ echo "cache-to=type=gha,mode=max,scope=build-base-${{ inputs.idris-version }}" >> $GITHUB_OUTPUT
44
+ else
45
+ echo "cache-to=" >> $GITHUB_OUTPUT
46
+ fi
47
+ shell : bash
36
48
37
49
- name : Build Base (versioned)
38
50
uses : docker/build-push-action@v5
@@ -47,10 +59,13 @@ runs:
47
59
load : ${{ inputs.load }}
48
60
push : ${{ inputs.push }}
49
61
labels : ${{ inputs.labels }}
50
- # When doing matrix builds, we need to scope the image
51
- # https://github.com/moby/buildkit/issues/2885
52
- cache-from : type=gha,scope=build-base-${{ inputs.idris-version }}
53
- cache-to : type=gha,mode=max,scope=build-base-${{ inputs.idris-version }}
62
+ # Along with caching from gha, also cache from gh registry
63
+ # the gha cache is limited to 10GB and I think i cause a lot of cache thrashing
64
+ # when I also make PRs, it seems that the cache is not shared, so I'll need to look into this
65
+ cache-from : |
66
+ type=gha,scope=build-base-${{ inputs.idris-version }}
67
+ type=registry,ref=ghcr.io/joshuanianji/idris-2-docker/base:${{ inputs.idris-version }}
68
+ cache-to : ${{ steps.calculate-cache-to.outputs.cache-to }}
54
69
55
70
- name : Build Base (latest)
56
71
uses : docker/build-push-action@v5
66
81
load : ${{ inputs.load }}
67
82
push : ${{ inputs.push }}
68
83
labels : ${{ inputs.labels }}
69
- # When doing matrix builds, we need to scope the image
70
- # https://github.com/moby/buildkit/issues/2885
71
- cache-from : type=gha,scope=build-base- ${{ inputs.idris-version }}
72
- cache-to : type=gha,mode=max,scope=build-base- ${{ inputs.idris-version }}
84
+ cache-from : |
85
+ type=gha,scope=build-base-${{ inputs.idris-version }}
86
+ type=registry,ref=ghcr.io/joshuanianji/idris-2-docker/base: ${{ inputs.idris-version }}
87
+ cache-to : ${{ steps.calculate-cache-to.outputs.cache-to }}
0 commit comments