-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
39 lines (34 loc) · 1.75 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
39 lines (34 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# cloudbuild.yaml is documented here:
# https://cloud.google.com/container-builder/docs/build-config
# basic concepts are addressed here:
# https://cloud.google.com/container-builder/docs/overview
# Cloud builders (as specified in the "name" parameters) are introduced here:
# https://cloud.google.com/container-builder/docs/cloud-builders
# Handling SSH key for accessing private repositories has this tutorial:
# https://cloud.google.com/container-builder/docs/access-private-github-repos
# Uses substitution variable _SERVICE_NAME (i.e. "svc-geometa") that should be
# defined in the GCP Container Builder Build Trigger.
# get go package dependencies using SSH
steps:
- name: 'gcr.io/cloud-builders/go'
args: ['get', '-t']
env: ['PROJECT_ROOT=app']
# go install the project
- name: 'gcr.io/cloud-builders/go'
args: ['install', '.']
env: ['PROJECT_ROOT=app']
# go test the unit tests for project
- name: 'gcr.io/cloud-builders/go'
args: ['test', 'app']
env: ['PROJECT_ROOT=app']
# build the docker image
# NOTE: if this build is triggered on every commit to master, it will not have a tag
# name. So the image name would end with a colon (which is invalid). If you tagged a
# commit, and the build is triggered on a tag, then everything is fine. To allow for
# both types of build triggers, we use a $(_COLON) substitution variable. In the
# "commit" trigger context, don't define the variable, and it is replaced with an
# empty string in the image name (which is valid). In the "tag" commit context,
# define $(_COLON)=":", and the image will be properly tagged.
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/$PROJECT_ID/${_SERVICE_NAME}${_COLON}$TAG_NAME', '.']
images: ['gcr.io/$PROJECT_ID/${_SERVICE_NAME}${_COLON}$TAG_NAME']