-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudbuild.yaml
89 lines (82 loc) · 2.33 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
steps:
# 0. Docker Build
- name: gcr.io/cloud-builders/docker
args:
- build
- '--no-cache'
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- .
- '-f'
- Dockerfile
id: Build
# 1. Docker push to Google Artifact Registry
- name: gcr.io/cloud-builders/docker
args:
- push
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
id: Push
# 2. Make migrations
- name: gcr.io/google-appengine/exec-wrapper
args:
- '-i'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '-s'
- '${PROJECT_ID}:${_DEPLOY_REGION}:${_DB_INSTANCE}'
- '-e'
- 'SETTINGS_NAME=${_SECRET_SETTINGS_NAME}'
- '--'
- 'python'
- 'manage.py'
- 'makemigrations'
id: Make migrations
# 3. Migrate
- name: gcr.io/google-appengine/exec-wrapper
args:
- '-i'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '-s'
- '${PROJECT_ID}:${_DEPLOY_REGION}:${_DB_INSTANCE}'
- '-e'
- 'SETTINGS_NAME=${_SECRET_SETTINGS_NAME}'
- '--'
- 'python'
- 'manage.py'
- 'migrate'
id: Migrate
# 4. Collect static
- name: gcr.io/google-appengine/exec-wrapper
args:
- '-i'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '-s'
- '${PROJECT_ID}:${_DEPLOY_REGION}:${_DB_INSTANCE}'
- '-e'
- 'SETTINGS_NAME=${_SECRET_SETTINGS_NAME}'
- '--'
- 'python'
- 'manage.py'
- 'collectstatic'
- '--no-input'
id: Collect static
# 5. Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
args:
- run
- services
- update
- $_SERVICE_NAME
- '--platform=managed'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- >-
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS
- '--region=$_DEPLOY_REGION'
- '--quiet'
id: Deploy
entrypoint: gcloud
# Store images in Google Artifact Registry
images:
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
tags:
- gcp-cloud-build-deploy-cloud-run
- gcp-cloud-build-deploy-cloud-run-managed