forked from memochou1993/gpt-ai-assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
68 lines (63 loc) · 1.95 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#if you need to use submodule please follow this link (https://cloud.google.com/build/docs/access-github-from-build)
steps:
# stop before build
- id: 'stop_before_build'
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- -c
- |
on_going_build=($(gcloud builds list --ongoing --format='value(id)' --filter="substitutions.TRIGGER_NAME=$TRIGGER_NAME" | xargs))
for (( i=0; i<${#on_going_build[@]}; i++ )); do
if [ "$i" -gt "0" ]; then # skip current
echo "Cancelling build ${on_going_build[i]}"
gcloud builds cancel ${on_going_build[i]}
fi
done
# build the container image
- id: 'build_container'
name: 'gcr.io/kaniko-project/executor:latest'
args:
- --destination=gcr.io/$PROJECT_ID/$REPO_NAME-$BRANCH_NAME
- --cache=true
- --cache-ttl=48h
- --build-arg
- OPENAI_API_KEY=$_OPENAI_API_KEY
- --build-arg
- LINE_CHANNEL_ACCESS_TOKEN=$_LINE_CHANNEL_ACCESS_TOKEN
- --build-arg
- LINE_CHANNEL_SECRET=$_LINE_CHANNEL_SECRET
- --build-arg
- APP_LANG=$_APP_LANG
- --build-arg
- APP_PORT=$_APP_PORT
- --build-arg
- OPENAI_TIMEOUT=$_OPENAI_TIMEOUT
- --build-arg
- LINE_TIMEOUT=$_LINE_TIMEOUT
- --build-arg
- LINE_USERS_WHITELIST=$_LINE_USERS_WHITELIST
# Deploy container image to Cloud Run
- id: 'deploy_registry_to_cloudrun'
name: 'gcr.io/cloud-builders/gcloud'
args:
[
'beta',
'run',
'deploy',
'$REPO_NAME-$BRANCH_NAME',
'--image',
'gcr.io/$PROJECT_ID/$REPO_NAME-$BRANCH_NAME',
'--region',
'asia-southeast1',
'--platform',
'managed',
'--port',
'3000',
# '--vpc-connector', # set vpc connector for connecting to DB with private ip
# 'superdev-vpc',
'--quiet',
]
timeout: 2000s
# options:
# machineType: 'N1_HIGHCPU_8'