-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcloudbuild.yaml
46 lines (41 loc) · 1.48 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
steps:
# clone the git repository
- name: "gcr.io/cloud-builders/git"
args:
["clone", "https://github.com/sungchun12/serverless_data_pipeline_gcp"]
# Deploy cloud function with pub/sub trigger from clone directory
- name: "gcr.io/cloud-builders/gcloud"
args:
[
"functions",
"deploy",
"demo_function",
"--entry-point",
"handler",
"--runtime",
"python37",
"--trigger-topic",
"demo_topic",
]
dir: "serverless_data_pipeline_gcp/src"
# Deploy cloud scheduler job which publishes a message to Pub/Sub every 5 minutes
# exits if it already exists
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
- "-c"
- |
gcloud beta scheduler jobs create pubsub schedule_function \
--schedule "*/5 * * * *" \
--topic demo_topic \
--message-body '{"Can you see this? With love, cloud scheduler"}' \
--time-zone 'America/Chicago' || exit 0
# Manually run the cloud scheduler job
- name: "gcr.io/cloud-builders/gcloud"
args: ["beta", "scheduler", "jobs", "run", "schedule_function"]
# Check logs to see how function performed.
- name: "gcr.io/cloud-builders/gcloud"
args: ["functions", "logs", "read", "--limit", "50"]
# set logs bucket location for builds
# set this to whatever bucket you want or remove entirely and cloudbuild will create a default bucket
logsBucket: "gs://cloud_function_build_demo"