-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
46 lines (42 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
43
44
45
46
substitutions:
_GH_REPO: "jimangel/docsy-gcs-buckets"
_ENVIRONMENT: "production"
_SITE_URL: "gcs.gitdocs.dev"
_STAGE_BUCKET_URL: "pr-${_PR_NUMBER}.gitdocs.dev"
options:
logging: GCS_ONLY
steps:
- id: 'init submodules'
name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- -c
- |
git submodule update --init --recursive
- id: 'Generate HUGO site'
name: 'gcr.io/cloud-builders/docker'
args: ['run', '--rm', '-v', '/workspace:/src', 'klakegg/hugo:0.77.0-ext-alpine']
- id: 'Copy files to bucket'
name: 'gcr.io/cloud-builders/gsutil'
entrypoint: 'bash'
args:
- -c
- |
echo "Deploying $_ENVIRONMENT bucket"
case $_ENVIRONMENT in
production)
gsutil -m rsync -R /workspace/public gs://${_SITE_URL}
gsutil iam ch allUsers:objectViewer gs://${_SITE_URL}
gsutil web set -m index.html -e 404.html gs://${_SITE_URL}
;;
staging)
gsutil mb -b on gs://${_STAGE_BUCKET_URL}
gsutil -m rsync -R /workspace/public gs://${_STAGE_BUCKET_URL}
gsutil iam ch allUsers:objectViewer gs://${_STAGE_BUCKET_URL}
gsutil web set -m index.html -e 404.html gs://${_STAGE_BUCKET_URL}
# delete after 30 days
gsutil lifecycle set /workspace/staging-gcs-lifecycle.json gs://${_STAGE_BUCKET_URL}
;;
*)
echo "environment $_ENVIRONMENT not production or staging; ignored."
esac