update cloudbuild for image pushing job

This commit is contained in:
Donny Xia
2020-10-30 11:45:40 -07:00
parent 981959ffcf
commit 9ae07634f2

View File

@@ -7,12 +7,8 @@ steps:
- "Cloud build substitution check: "
- "BUILD_ID=$BUILD_ID"
- "PROJECT_ID=$PROJECT_ID"
- "REVISION_ID=$REVISION_ID"
- "REPO_NAME=$REPO_NAME"
- "COMMIT_SHA=$COMMIT_SHA"
- "BRANCH_NAME=$BRANCH_NAME"
- "TAG_NAME=$TAG_NAME"
- "_GIT_TAG=$_GIT_TAG"
- "_PULL_BASE_REF=$_PULL_BASE_REF"
# We need to use bash to configure the build date properly.
- name: "gcr.io/cloud-builders/docker"
entrypoint: /bin/bash
@@ -22,23 +18,31 @@ steps:
docker
build
-t
gcr.io/$PROJECT_ID/$_MODULE_NAME:$_MODULE_VERSION
gcr.io/$PROJECT_ID/kustomize:${_GIT_TAG}
-t
gcr.io/$PROJECT_ID/$_MODULE_NAME:latest
gcr.io/$PROJECT_ID/kustomize:latest
-f
kustomize.Dockerfile
--build-arg
VERSION=$TAG_NAME
VERSION=${_VERSION}
--build-arg
COMMIT=$COMMIT_SHA
COMMIT=$(git rev-parse HEAD)
--build-arg
DATE=`date -u +%FT%TZ`
.
images:
- "gcr.io/$PROJECT_ID/$_MODULE_NAME:$_MODULE_VERSION"
- "gcr.io/$PROJECT_ID/$_MODULE_NAME:latest"
- "gcr.io/$PROJECT_ID/kustomize:${_GIT_TAG}"
- "gcr.io/$PROJECT_ID/kustomize:latest"
substitutions:
_MODULE_NAME: ${TAG_NAME%/*}
_MODULE_VERSION: ${TAG_NAME#*/}
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
# can be used as a substitution
_GIT_TAG: "12345"
# _PULL_BASE_REF will contain the ref that was pushed to to trigger this build -
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
_PULL_BASE_REF: "master"
_VERSION: ${_PULL_BASE_REF#*/}
options:
substitution_option: ALLOW_LOOSE