Skip to content

Commit af8fc51

Browse files
committed
Limit Cache push to main branch
1 parent 9f431a6 commit af8fc51

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.gitlab/ci/container-build.gitlab-ci.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,20 @@
2525
- amd64
2626
- arm64
2727
script:
28+
- CACHE_TO=""
29+
- |
30+
if [ "$C0_GH_REF_NAME" = "main" ]; then
31+
CACHE_TO="--cache-to type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${PLATFORM}"
32+
fi
2833
- >
2934
build_image
3035
$image
3136
$CI_PIPELINE_ID
3237
"
3338
--output type=registry,push-by-digest=true
3439
--metadata-file manifest-${CI_JOB_ID}.json
35-
--cache-to type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${PLATFORM}
3640
--cache-from type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${PLATFORM}
41+
$CACHE_TO
3742
"
3843
""
3944
artifacts:
@@ -45,6 +50,11 @@
4550
extends:
4651
- .image-build-base
4752
script:
53+
- CACHE_TO=""
54+
- |
55+
if [ "$C0_GH_REF_NAME" = "main" ]; then
56+
CACHE_TO="--cache-to type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${VARIANT}-${PLATFORM}"
57+
fi
4858
- >
4959
build_image
5060
$image
@@ -53,8 +63,8 @@
5363
--build-arg VARIANT=$VARIANT
5464
--output type=registry,push-by-digest=true
5565
--metadata-file manifest-${CI_JOB_ID}.json
56-
--cache-to type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${VARIANT}-${PLATFORM}
5766
--cache-from type=registry,ref=ghcr.io/code0-tech/reticulum/ci-cache:${image}-${VARIANT}-${PLATFORM}
67+
$CACHE_TO
5868
"
5969
""
6070
artifacts:

0 commit comments

Comments
 (0)