-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
74 lines (67 loc) · 2.09 KB
/
cloudbuild.yaml
File metadata and controls
74 lines (67 loc) · 2.09 KB
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
steps:
- name: 'gcr.io/cloud-builders/gsutil'
id: 'restore cache'
entrypoint: 'sh'
args:
- '-c'
- |
HASH=$(sha256sum yarn.lock | cut -d' ' -f1)
CACHE_PATH="gs://coinspace-production-cs-dex-us/${_NAMESPACE}/cache/node_modules_$${HASH}.tar.gz"
if gsutil -q stat "$$CACHE_PATH"; then
echo "✅ Cache found: $$CACHE_PATH"
gsutil cp "$$CACHE_PATH" node_modules.tar.gz
tar -xzf node_modules.tar.gz node_modules
rm node_modules.tar.gz
else
echo "No cache found for hash: $$HASH"
fi
- name: 'node:22.20.0'
id: 'build web'
entrypoint: 'bash'
args:
- '-c'
- |
yarn install --frozen-lockfile --prefer-offline \
&& yarn build:spa
env:
- 'VITE_COMMIT=${COMMIT_SHA}'
- name: 'gcr.io/cloud-builders/gsutil'
id: 'save cache'
entrypoint: 'sh'
args:
- '-c'
- |
HASH=$(sha256sum yarn.lock | cut -d' ' -f1)
CACHE_PATH="gs://coinspace-production-cs-dex-us/${_NAMESPACE}/cache/node_modules_$${HASH}.tar.gz"
if ! gsutil -q stat "$$CACHE_PATH"; then
echo "✅ Saving cache: $$CACHE_PATH"
tar -czf node_modules.tar.gz node_modules \
&& gsutil cp node_modules.tar.gz "$$CACHE_PATH" \
&& rm node_modules.tar.gz
else
echo "Cache exists: $$HASH"
fi
- name: 'gcr.io/cloud-builders/docker'
id: 'build server'
entrypoint: 'sh'
args:
- '-c'
- |
docker build --tag "gcr.io/$PROJECT_ID/${_NAMESPACE}/${_APP}:latest" . \
&& docker push "gcr.io/$PROJECT_ID/${_NAMESPACE}/${_APP}:latest"
- name: 'gcr.io/cloud-builders/kubectl'
id: 'deploy'
args: ['rollout', 'restart', 'deploy', '-l', 'app=${_APP}', '--namespace', '${_NAMESPACE}']
env:
- 'CLOUDSDK_COMPUTE_ZONE=${_CLOUDSDK_COMPUTE_ZONE}'
- 'CLOUDSDK_CONTAINER_CLUSTER=${_CLOUDSDK_CONTAINER_CLUSTER}'
- name: 'gcr.io/cloud-builders/gcloud'
id: 'purge cdn'
entrypoint: 'bash'
args:
- '-c'
- |
if [[ -n "${_CDN_URL_MAP_NAME}" ]]; then
gcloud compute url-maps invalidate-cdn-cache ${_CDN_URL_MAP_NAME} --host ${_CDN_HOST} --path "/*" --async
fi
timeout: 1800s