-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
42 lines (38 loc) · 1.39 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
timeout: 3600s
options:
env:
- PROJECT_ID=$PROJECT_ID
- WORKSPACE_LINK=/go/src/github.com/m-lab/autojoin
steps:
# Run unit tests for environment.
- name: gcr.io/$PROJECT_ID/golang-cbif:1.20
args:
- go version
- go get -v -t ./...
- go vet ./...
- go test ./... -race
- go test -v ./...
# Deployment of API.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.1
args:
- sed -i -e 's/{{PROJECT_ID}}/$PROJECT_ID/g' app.yaml
- sed -i -e 's/{{REDIS_ADDRESS}}/$_REDIS_ADDRESS/g' app.yaml
- gcloud --project $PROJECT_ID app deploy --promote app.yaml
# After deploying the new service, deploy the openapi spec.
- sed -i -e 's/{{PROJECT}}/$PROJECT_ID/' -e 's/{{DEPLOYMENT}}/$PROJECT_ID/' openapi.yaml
- gcloud endpoints services deploy openapi.yaml
# Deployment of dispatch for mlab-autojoin.
# Routes requests to autojoin.measurementlab.net to the autojoin service.
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.1
entrypoint: bash
args:
- -c
- |-
if [[ "$PROJECT_ID" == "mlab-autojoin" ]]; then
# Wait for the first non-completed operation.
gcloud --project $PROJECT_ID app operations wait \
$$( gcloud --project $PROJECT_ID app operations list \
| grep -vE 'STATUS|COMPLETED' | awk '{print $1}' | head -1 ) 2> /dev/null || :
# Deploy dispatch after operations are complete.
gcloud --project $PROJECT_ID app deploy dispatch.yaml ;
fi