63
63
id : imagename
64
64
run : |
65
65
IMG="${GITHUB_REPOSITORY,,}/base"
66
- DLIMG="${GITHUB_REPOSITORY,,}/dl_cache"
67
66
echo "name=ghcr.io/${IMG/ /-}" >> $GITHUB_OUTPUT
68
67
echo "rawname=${IMG/ /-}" >> $GITHUB_OUTPUT
69
- echo "dlname=ghcr.io/${DLIMG/ /-}" >> $GITHUB_OUTPUT
70
- echo "dlrawname=${DLIMG/ /-}" >> $GITHUB_OUTPUT
71
68
- name : Stop Commands
72
69
run : T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
73
70
- name : Build target base image
@@ -80,23 +77,22 @@ jobs:
80
77
tags : ${{ steps.imagename.outputs.name }}:latest
81
78
cache-to : type=registry,mode=max,ref=${{ steps.imagename.outputs.name }}:cache
82
79
cache-from : type=registry,ref=${{ steps.imagename.outputs.name }}:cache
83
- - name : Generate download cache Dockerfile
80
+ - name : Get download cache key
84
81
id : dl_cache
85
82
run : |
86
- ./generate.sh dl only
87
83
echo "dltagname=$(./util/get_dl_cache_tag.sh)" >> $GITHUB_OUTPUT
88
- cat Dockerfile.dl
89
- - name : Build download cache image
90
- uses : docker/build-push-action@v5
84
+ - name : Cache
85
+ uses : actions/cache@v3
91
86
with :
92
- context : .
93
- file : Dockerfile.dl
94
- pull : true
95
- push : true
96
- provenance : false
97
- tags : ${{ steps.imagename.outputs.dlname }}:${{ steps.dl_cache.outputs.dltagname }}
98
- cache-to : type=registry,mode=max,ref=${{ steps.imagename.outputs.dlname }}:cache
99
- cache-from : type=registry,ref=${{ steps.imagename.outputs.dlname }}:cache
87
+ path : .cache/downloads
88
+ key : download-cache-${{ steps.dl_cache.outputs.dltagname }}
89
+ restore-keys : |
90
+ download-cache-
91
+ - name : Update Cache
92
+ run : |
93
+ set -e
94
+ ./download.sh
95
+ ./util/clean_cache.sh
100
96
- name : Cleanup
101
97
if : ${{ env.HAVE_CLEANUP_PAT == 'true' }}
102
98
continue-on-error : true
@@ -108,18 +104,6 @@ jobs:
108
104
repository : ${{ github.repository }}
109
105
owner_type : user
110
106
untagged_only : true
111
- - name : Cleanup Download Cache
112
- if : ${{ env.HAVE_CLEANUP_PAT == 'true' }}
113
- continue-on-error : true
114
- uses : BtbN/delete-untagged-ghcr-action@main
115
- with :
116
- token : ${{ secrets.CLEANUP_PAT }}
117
- package_name : ${{ steps.imagename.outputs.dlrawname }}
118
- repository_owner : ${{ github.repository_owner }}
119
- repository : ${{ github.repository }}
120
- owner_type : user
121
- untagged_only : false
122
- keep_latest : 20
123
107
build_target_bases :
124
108
name : Build target base image
125
109
if : ${{ github.event.inputs.buildOnly != 'true' }}
@@ -201,16 +185,26 @@ jobs:
201
185
registry : ghcr.io
202
186
username : ${{ github.actor }}
203
187
password : ${{ github.token }}
204
- - name : Generate Dockerfile
205
- run : ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
206
188
- name : Image Name
207
189
id : imagename
208
190
run : |
209
191
IMG="${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
210
192
echo "name=ghcr.io/${IMG/ /-}" >> $GITHUB_OUTPUT
211
193
echo "rawname=${IMG/ /-}" >> $GITHUB_OUTPUT
194
+ - name : Get download cache key
195
+ id : dl_cache
196
+ run : |
197
+ echo "dltagname=$(./util/get_dl_cache_tag.sh)" >> $GITHUB_OUTPUT
212
198
- name : Stop Commands
213
199
run : T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
200
+ - name : Generate Dockerfile
201
+ run : ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
202
+ - name : Cache
203
+ uses : actions/cache/restore@v3
204
+ with :
205
+ path : .cache/downloads
206
+ key : download-cache-${{ steps.dl_cache.outputs.dltagname }}
207
+ fail-on-cache-miss : true
214
208
- name : Build target base image
215
209
uses : docker/build-push-action@v5
216
210
with :
0 commit comments