gke-deploy/doc/trigger.yaml (77 lines of code) (raw):
description: Deploy on push to any branch
github:
owner: @OWNER@
name: @REPO@
push:
branch: @BRANCH_REGEX@
build:
steps:
- id: Build
name: gcr.io/cloud-builders/docker
args:
- build
- -t
- $_IMAGE_NAME:$SHORT_SHA
- .
- -f
- $_DOCKERFILE_PATH
- id: Push
name: gcr.io/cloud-builders/docker
args:
- push
- $_IMAGE_NAME:$SHORT_SHA
- id: Prepare deploy
name: gcr.io/cloud-builders/gke-deploy
args:
- prepare
- --filename=$_K8S_YAML_PATH
- --image=$_IMAGE_NAME:$SHORT_SHA
- --app=$_K8S_APP_NAME
- --version=$SHORT_SHA
- --namespace=$_K8S_NAMESPACE
- --output=output
- --annotation=gcb-build-id=$BUILD_ID
- id: Save configs
name: gcr.io/cloud-builders/gsutil
entrypoint: sh
args:
- -c
- |
set -e
if [ $_OUTPUT_BUCKET_PATH ]; then
gsutil cp -r output/suggested gs://$_OUTPUT_BUCKET_PATH/config/$BUILD_ID/suggested
echo "Copied suggested base configs to gs://$_OUTPUT_BUCKET_PATH/config/$BUILD_ID/suggested"
gsutil cp -r output/expanded gs://$_OUTPUT_BUCKET_PATH/config/$BUILD_ID/expanded
echo "Copied expanded configs to gs://$_OUTPUT_BUCKET_PATH/config/$BUILD_ID/expanded"
fi
- id: Apply deploy
name: gcr.io/cloud-builders/gke-deploy
args:
- apply
- --filename=output/expanded
- --namespace=$_K8S_NAMESPACE
- --cluster=$_GKE_CLUSTER
- --location=$_GKE_LOCATION
images:
- $_IMAGE_NAME:$SHORT_SHA
substitutions:
_DOCKERFILE_PATH: Dockerfile
_IMAGE_NAME:
_GKE_CLUSTER:
_GKE_LOCATION:
_K8S_YAML_PATH:
_K8S_APP_NAME:
_K8S_NAMESPACE:
_OUTPUT_BUCKET_PATH:
options:
substitution_option: ALLOW_LOOSE
tags:
- $_K8S_APP_NAME
substitutions:
_IMAGE_NAME: @IMAGE_NAME@
_GKE_CLUSTER: @CLUSTER@
_GKE_LOCATION: @LOCATION@
_K8S_YAML_PATH: @CONFIGS@
_K8S_APP_NAME: @APP_NAME@
_K8S_NAMESPACE: @NAMESPACE@
_OUTPUT_BUCKET_PATH: @OUTPUT_BUCKET_PATH@