This repository has been archived by the owner on May 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.mask-web.yaml
82 lines (74 loc) · 2.22 KB
/
cloudbuild.mask-web.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
# Decrypt the file containing the key
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=id_rsa.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=my-keyring
- --key=github-key
volumes:
- name: 'ssh'
path: /root/.ssh
# Set up git with key and domain
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
chmod 600 /root/.ssh/id_rsa
cat <<EOF >/root/.ssh/config
Hostname github.com
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
# Cloud Build x GitHub integration uses source archives to fetch
# the source, rather than Git source fetching, and as a consequence
# does not include the .git/ directory. As a workaround, we clone
# the repository and reset it to this build's commit sha.
git clone '[email protected]:cage1016/mask-gae.git' tmp
mv tmp/.git .git
rm -rf tmp
git config user.email $(gcloud auth list --filter=status:ACTIVE --format='value(account)')
git reset "$COMMIT_SHA"
git submodule sync --recursive
git submodule update --init --recursive
cd website/mask-web
git checkout -t origin/release
git pull
cd ../..
git add website/mask-web
git commit -m 'swtich release to prepare release build'
volumes:
- name: 'ssh'
path: /root/.ssh
- name: 'gcr.io/cloud-builders/npm'
dir: 'website/mask-web'
args:
- install
- name: 'gcr.io/mask-9999/ng:v9'
dir: 'website/mask-web'
args:
- build
- --prod
- name: gcr.io/cloud-builders/gcloud
entrypoint: 'bash'
args:
- '-c'
- |
# get mask-web short sha
maskWebShortSha=$(git ls-files -s website/mask-web | awk '{print substr($2,0,7)}')
# deploy
gcloud app deploy --version=${maskWebShortSha} website/app.yaml --no-promote -q
echo "deploy succeeded."
timeout: "1600s"