-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
27 lines (27 loc) · 1.08 KB
/
cloudbuild.yaml
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
steps:
# Build the container image
- id: build-image
name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-f', 'Dockerfile', '-t', '${_IMAGE}:$BRANCH_NAME-$SHORT_SHA', '.']
# Run container
- id: run-container
name: 'gcr.io/cloud-builders/docker'
args: ['run', '-p', '80:8000', '-d', '--name', 'bot-server', '${_IMAGE}:$BRANCH_NAME-$SHORT_SHA']
waitFor: [build-image]
# Execute container & Run test
- id: exec-container
name: 'gcr.io/cloud-builders/docker'
args: ['exec', 'bot-server', 'go', 'test', './...']
waitFor: [run-container]
# Push the image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', '${_IMAGE}:$BRANCH_NAME-$SHORT_SHA']
# Deploy image to Cloud Run
- name: 'gcr.io/cloud-builders/gcloud'
args: ['beta', 'run', 'deploy', '${_SERVICE_NAME}', '--image', '${_IMAGE}:$BRANCH_NAME-$SHORT_SHA', '--region', '${_REGION}', '--platform', 'managed', '--allow-unauthenticated']
images:
- ${_IMAGE}:$BRANCH_NAME-$SHORT_SHA
substitutions:
_IMAGE: asia.gcr.io/dictionary-chatbot/dictionary-bot
_SERVICE_NAME: dictionary-bot
_REGION: asia-northeast1