Skip to content

Commit 85e6e34

Browse files
authored
Write images to GH cache on main & release branches (#8713)
1 parent 9db2233 commit 85e6e34

File tree

7 files changed

+25
-4
lines changed

7 files changed

+25
-4
lines changed

.github/workflows/build-artifacts.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ on:
4343
image-matrix-nap:
4444
required: true
4545
type: string
46+
write-to-cache:
47+
description: Whether to write built images to cache
48+
type: boolean
49+
default: false
4650

4751
defaults:
4852
run:
@@ -208,6 +212,7 @@ jobs:
208212
branch: ${{ inputs.branch }}
209213
ic-version: ${{ inputs.ic-version }}
210214
runner: ${{ inputs.runner }}
215+
write-to-cache: ${{ inputs.write-to-cache }}
211216
permissions:
212217
contents: read
213218
actions: read
@@ -235,6 +240,7 @@ jobs:
235240
full-build: ${{ inputs.force }}
236241
ic-version: ${{ inputs.ic-version }}
237242
runner: ${{ inputs.runner }}
243+
write-to-cache: ${{ inputs.write-to-cache }}
238244
permissions:
239245
contents: read
240246
id-token: write
@@ -261,6 +267,7 @@ jobs:
261267
full-build: ${{ inputs.force }}
262268
ic-version: ${{ inputs.ic-version }}
263269
runner: ${{ inputs.runner }}
270+
write-to-cache: ${{ inputs.write-to-cache }}
264271
permissions:
265272
contents: read
266273
id-token: write # gcr login

.github/workflows/build-oss.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ on:
3434
runner:
3535
type: string
3636
default: ubuntu-24.04
37+
write-to-cache:
38+
required: false
39+
type: boolean
40+
default: false
3741

3842
defaults:
3943
run:
@@ -177,7 +181,7 @@ jobs:
177181
with:
178182
file: build/Dockerfile
179183
context: "."
180-
cache-to: type=gha,scope=${{ inputs.image }},mode=max
184+
cache-to: ${{ inputs.write-to-cache && format('type=gha,scope={0},mode=max', inputs.image) || '' }}
181185
target: common
182186
tags: ${{ steps.base_name.outputs.image }}
183187
platforms: ${{ inputs.platforms }}
@@ -211,7 +215,7 @@ jobs:
211215
file: build/Dockerfile
212216
context: "."
213217
cache-from: type=gha,scope=${{ inputs.image }}
214-
cache-to: type=gha,scope=${{ inputs.image }},mode=max
218+
cache-to: ${{ inputs.write-to-cache && format('type=gha,scope={0},mode=max', inputs.image) || '' }}
215219
target: goreleaser${{ inputs.authenticated && '-prebuilt' || '' }}
216220
tags: ${{ steps.meta.outputs.tags }}
217221
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/build-plus.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ on:
4040
runner:
4141
type: string
4242
default: ubuntu-24.04
43+
write-to-cache:
44+
required: false
45+
type: boolean
46+
default: false
4347

4448
defaults:
4549
run:
@@ -200,7 +204,7 @@ jobs:
200204
with:
201205
file: build/Dockerfile
202206
context: "."
203-
cache-to: type=gha,scope=${{ inputs.image }}${{ steps.nap_modules.outputs.name != '' && format('-{0}', steps.nap_modules.outputs.name) || '' }},mode=max
207+
cache-to: ${{ inputs.write-to-cache && format('type=gha,scope={0}{1},mode=max', inputs.image, steps.nap_modules.outputs.name != '' && format('-{0}', steps.nap_modules.outputs.name) || '' ) || '' }}
204208
target: common
205209
tags: ${{ steps.base_name.outputs.image }}
206210
platforms: ${{ inputs.platforms }}
@@ -239,7 +243,7 @@ jobs:
239243
file: build/Dockerfile
240244
context: "."
241245
cache-from: type=gha,scope=${{ inputs.image }}${{ steps.nap_modules.outputs.name != '' && format('-{0}', steps.nap_modules.outputs.name) || '' }}
242-
cache-to: type=gha,scope=${{ inputs.image }}${{ steps.nap_modules.outputs.name != '' && format('-{0}', steps.nap_modules.outputs.name) || '' }},mode=max
246+
cache-to: ${{ inputs.write-to-cache && format('type=gha,scope={0}{1},mode=max', inputs.image, steps.nap_modules.outputs.name != '' && format('-{0}', steps.nap_modules.outputs.name) || '' ) || '' }}
243247
target: ${{ inputs.target }}${{ inputs.authenticated && '-prebuilt' || '' }}
244248
tags: ${{ steps.meta.outputs.tags }}
245249
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/cache-update.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
authenticated: false
5454
tag: "edge"
5555
branch: ${{ github.ref }}
56+
write-to-cache: true
5657
permissions:
5758
contents: read
5859
actions: read
@@ -78,6 +79,7 @@ jobs:
7879
authenticated: false
7980
tag: "edge"
8081
branch: ${{ github.ref }}
82+
write-to-cache: true
8183
permissions:
8284
contents: read
8385
security-events: write
@@ -102,6 +104,7 @@ jobs:
102104
authenticated: false
103105
tag: "edge"
104106
branch: ${{ github.ref }}
107+
write-to-cache: true
105108
permissions:
106109
contents: read
107110
security-events: write

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ jobs:
356356
ic-version: ${{ needs.checks.outputs.ic_version }}
357357
authenticated: ${{ needs.checks.outputs.forked_workflow != 'true' }}
358358
runner: ubuntu-24.04
359+
write-to-cache: false
359360
permissions:
360361
contents: read
361362
actions: read

.github/workflows/image-promotion.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ jobs:
188188
go-md5: ${{ needs.checks.outputs.go_code_md5 }}
189189
docker-md5: ${{ needs.checks.outputs.docker_md5 }}
190190
runner: "ubuntu-24.04-amd64"
191+
write-to-cache: true
191192
secrets: inherit
192193
permissions:
193194
contents: read

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ jobs:
112112
go-md5: ${{ needs.variables.outputs.go_code_md5 }}
113113
docker-md5: ${{ needs.variables.outputs.docker_md5 }}
114114
runner: "ubuntu-24.04-amd64"
115+
write-to-cache: true
115116
secrets: inherit
116117
permissions:
117118
contents: read

0 commit comments

Comments
 (0)