-
Notifications
You must be signed in to change notification settings - Fork 1
/
cloudbuild.yaml
103 lines (92 loc) · 2.94 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# In this directory, run the following command to build this builder.
# $ gcloud builds submit . --config=cloudbuild.yaml
timeout: 300s
steps:
# Check project GCR for current available images.
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud container images list-tags gcr.io/$PROJECT_ID/hugo --format=json > gcrimagelist.json
gcloud container images list-tags gcr.io/$PROJECT_ID/frbtools --format=json > gcrfrbimglist.json
id: 'check-images'
# Run 'update.py' to check current Hugo version and update 'Dockerfile.hugo-xtnd' accordingly.
- name: 'python:3.7'
entrypoint: 'bash'
args:
- '-c'
- |
python --version
git config --global user.email "[YOUR_EMAIL]"
git config --global user.name "[YOUR_NAME]"
pip3 install requests gitpython
python ./update.py
id: 'update'
# Update the actual Google Cloud Sources repo
- name: 'gcr.io/cloud-builders/git'
args:
- 'push'
- '-f'
- 'https://source.developers.google.com/p/$PROJECT_ID/r/$REPO_NAME'
- 'master'
- '--follow-tags'
id: 'sources-update'
# Build hugo extended most current version and tag accordingly
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- './imgbuilder.bash'
env:
- 'PROJECT=$PROJECT_ID'
- 'VRSNFILE=buildhugo.txt'
- 'IMGNAME=hugo'
- 'DCRFILE=Dockerfile-hugo-xtnd'
- 'SEARCHSTR="ENV HUGO_VERSION"'
# Test if an image build with current hugo extended works
- name: 'gcr.io/$PROJECT_ID/hugo'
args: ['--help']
id: 'test'
# Build site
# All available Hugo versions are listed here: gcr.io/$PROJECT_ID/hugo (private)
- name: 'gcr.io/$PROJECT_ID/hugo'
id: 'site-builder'
# Check if the site is built
- name: busybox
args: ['cat', 'public/index.xml']
# Build Firebase tools most current version and tag accordingly
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- './imgbuilder.bash'
env:
- 'PROJECT=$PROJECT_ID'
- 'VRSNFILE=buildfrtls.txt'
- 'IMGNAME=frbtools'
- 'DCRFILE=Dockerfile-firebase'
- 'SEARCHSTR="ENV FRBTOOLS_VERSION"'
id: 'frbtools-image'
waitFor: ['sources-update']
# Test Firebase tools
- name: 'gcr.io/$PROJECT_ID/frbtools'
args:
- 'list'
secretEnv: ['FIREBASE_TOKEN']
waitFor: ['frbtools-image', 'test']
# Deploy to Firebase hosting
- name: 'gcr.io/$PROJECT_ID/frbtools'
args:
- '--project'
- '[YOUR_PROJECT_ID]'
- '--non-interactive'
- 'deploy'
- '--only'
- 'hosting'
- '--message'
- 'Build $BUILD_ID, repo $REPO_NAME, sha1 $COMMIT_SHA, ref $BRANCH_NAME'
secretEnv: ['FIREBASE_TOKEN']
# Decrypt encrypted FIREBASE_TOKEN using key 'firebase-token' from keyring 'cloudbuilder'
secrets:
- kmsKeyName: 'projects/[YOUR_PROJECT_ID]/locations/global/keyRings/cloudbuilder/cryptoKeys/firebase-token'
secretEnv:
FIREBASE_TOKEN: '[YOUR_ENCRYPTED_FIREBASE_TOKEN]'