Skip to content

Commit ee45c46

Browse files
committed
allow cloudbuild to build git tags
Use the K8s-/Prow-provided _PULL_BASE_REF substitution variable [1] to build images with tags based on the git commit tag. By the K8s docs, this should work, but it remains to be tested. [1] https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions Signed-off-by: Blaine Gardner <[email protected]>
1 parent 854c289 commit ee45c46

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: cloudbuild.yaml

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config
2-
# Builds go to: https://console.cloud.google.com/gcr/images/k8s-staging-test-infra/global/
2+
# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-test-infra/global/
3+
# Build logs in https://testgrid.k8s.io/sig-storage-image-build
34
timeout: 3000s
45
options:
56
substitution_option: 'ALLOW_LOOSE'
@@ -19,10 +20,15 @@ steps:
1920
args:
2021
- buildx
2122
- build
22-
- --platform="linux/amd64,linux/arm64"
23+
- --platform=linux/amd64,linux/arm64
2324
- --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller:${_GIT_TAG}
25+
# using _PULL_BASE_REF as a tag will often just build and overwrite the same 'master' tag,
26+
# BUT! if the commit has a git tag, it will build that tag instead. this mechanism allows
27+
# creating the semver-tagged images that will be auto-promoted to release
28+
- --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller:${_PULL_BASE_REF}
2429
- --tag=gcr.io/k8s-staging-sig-storage/objectstorage-controller:latest
2530
- .
2631
images:
2732
- gcr.io/k8s-staging-sig-storage/objectstorage-controller:${_GIT_TAG}
33+
- gcr.io/k8s-staging-sig-storage/objectstorage-controller:${_PULL_BASE_REF}
2834
- gcr.io/k8s-staging-sig-storage/objectstorage-controller:latest

0 commit comments

Comments
 (0)