-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create CD script to be run after every push to main branch
Hook up guestbook-go (first) to push images to the staging project with prow.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
# cd to the repo root | ||
REPO_ROOT=$(git rev-parse --show-toplevel) | ||
cd "${REPO_ROOT}" | ||
|
||
if [ -z "${GIT_REF:-}" ]; then | ||
echo "GIT_REF must be set" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${REGISTRY_BASE:-}" ]]; then | ||
echo "REGISTRY_BASE must be set" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! "${GIT_REF}" =~ ^refs/heads/.* ]]; then | ||
echo "GIT_REF=${GIT_REF} is not of the expected format refs/heads/*" | ||
exit 1 | ||
fi | ||
|
||
BRANCH=${GIT_REF/refs\/heads\//} | ||
echo "BRANCH is ${BRANCH}" | ||
|
||
GIT_REVISION=$(git rev-parse --short HEAD) | ||
echo "GIT_REVISION is ${GIT_REVISION}" | ||
|
||
export IMAGE_TAG="g${GIT_REVISION}" | ||
echo "IMAGE_TAG is ${IMAGE_TAG}" | ||
|
||
pushd ${REPO_ROOT}/guestbook-go | ||
VERSION=${IMAGE_TAG} REGISTRY=${REGISTRY_BASE} make push | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
timeout: 900s | ||
steps: | ||
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20230111-cd1b3caf9c' | ||
entrypoint: dev/cd/after-push-to-branch | ||
env: | ||
- GIT_REF=$_GIT_TAG | ||
- PULL_BASE_REF=$_PULL_BASE_REF | ||
- REGISTRY_BASE=gcr.io/k8s-staging-examples | ||
substitutions: | ||
# _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: 'master' |