Skip to content

Commit 5fbd979

Browse files
committed
done
1 parent e04c848 commit 5fbd979

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.github/workflows/_reusable-build-images.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ jobs:
3131
with:
3232
python-version: ${{ inputs.python-version }}
3333
expose-github-runtime: 'true'
34+
- name: Set DISABLE_CACHE_TO for PRs, no need to bloat the github cache
35+
id: set-disable-cache-to
36+
run: |
37+
# Only enable cache-to on master/main
38+
if [[ "${GITHUB_REF##*/}" == "master" || "${GITHUB_REF##*/}" == "main" ]]; then
39+
echo "DISABLE_CACHE_TO=" >> $GITHUB_ENV
40+
else
41+
echo "DISABLE_CACHE_TO=1" >> $GITHUB_ENV
42+
fi
3443
- name: build backend images
3544
if: ${{ inputs.build-backend }}
3645
run: |

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ DOCKER_BUILDX_CACHE_FROM ?= /tmp/.buildx-cache
178178
DOCKER_BUILDX_CACHE_TO ?= /tmp/.buildx-cache
179179
DOCKER_TARGET_PLATFORMS ?= linux/amd64
180180
comma := ,
181+
DISABLE_CACHE_TO ?= 0
182+
183+
181184

182185
define _docker_compose_build
183186
$(eval INCLUDED_SERVICES := $(filter-out $(exclude), $(SERVICES_NAMES_TO_BUILD))) \
@@ -211,8 +214,9 @@ docker buildx bake --allow=fs.read=.. \
211214
--file docker-compose-build.yml $(if $(target),$(target),$(INCLUDED_SERVICES)) \
212215
$(if $(findstring -nc,$@),--no-cache,\
213216
$(foreach service, $(SERVICES_NAMES_TO_BUILD),\
214-
--set $(service).cache-to=type=gha$(comma)mode=max$(comma)scope=$(service) \
215-
--set $(service).cache-from=type=gha$(comma)scope=$(service)) \
217+
$(if $(DISABLE_CACHE_TO),,\
218+
--set $(service).cache-to=type=gha$(comma)mode=max$(comma)scope=$(service) ) \
219+
--set $(service).cache-from=type=gha$(comma)scope=$(service)) \
216220
) &&\
217221
popd;
218222
endef

0 commit comments

Comments
 (0)