-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgcp-deploy.sh
More file actions
executable file
·130 lines (104 loc) · 4.22 KB
/
Copy pathgcp-deploy.sh
File metadata and controls
executable file
·130 lines (104 loc) · 4.22 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
# Each `gcloud app deploy` invocation below uses a yaml whose containing
# folder (client/, server/, GCP/) is the source directory; client/ and
# server/ each ship a .gcloudignore that scopes the upload to the runtime
# artefacts (dist/ and php source respectively). No upload happens from
# the repo root, so no root .gcloudignore is needed.
#
# set -euo pipefail: any failed gcloud / docker / sub-script aborts the
# whole orchestrator instead of silently continuing - the previous
# behaviour let a failed front build propagate as a successful "deploy"
# (cf. May-2025 prod front skipped without surfacing the error).
set -euo pipefail
COUNTRY=$1
ENV=$2
TARGET=$3
if [[ "${COUNTRY}1" != "fr1" ]]
then
echo "'${COUNTRY}' the first parameter (country) is not valid. Valid values are ['fr']"
exit 1
fi
if [[ "${ENV}1" != "dev1" ]] && [[ "${ENV}1" != "test1" ]] && [[ "${ENV}1" != "prod1" ]]
then
echo "'${ENV}' the second parameter (env) is not valid. Valid values are ['dev', 'test', 'prod']"
exit 1
fi
if [[ "${TARGET}1" == "1" ]]
then
echo "Deploying All artifacts"
TARGET="all"
fi
if [[ "${TARGET}1" != "all1" ]] && [[ "${TARGET}1" != "route1" ]] && [[ "${TARGET}1" != "front1" ]] && [[ "${TARGET}1" != "back1" ]] && [[ "${TARGET}1" != "fb1" ]] && [[ "${TARGET}1" != "functions1" ]]
then
echo "'${TARGET}' the third parameter (target) is not valid. Valid values are ['route', 'front', 'back', 'fb', 'functions', 'all']"
exit 1
fi
# 'fb' = back + front, in that order, sequentially in the same process.
# Same ordering as 'all' (DB migrations & API ship before the front that
# depends on them) but skips functions / dispatch routing. Sequential
# execution shares the gcloud global project state, so it is safe to
# rely on `setProject` at the top - the historical race condition only
# occurred when users ran two separate `./gcp-deploy.sh ... front &
# ./gcp-deploy.sh ... back` processes in parallel.
#load common functions
. GCP/common.sh
setProject "rcq-${COUNTRY}-${ENV}"
#list current connect google account
gcloud auth list
echo "Deploying ${TARGET}"
if [[ "${TARGET}1" == "all1" ]] || [[ "${TARGET}1" == "back1" ]] || [[ "${TARGET}1" == "fb1" ]]
then
echo
echo
echo "##############################################################"
echo "##############################################################"
echo "# BACK END #"
echo "##############################################################"
echo "##############################################################"
echo
echo
#deploy back project
GCP/deploy_back.sh "${COUNTRY}" "${ENV}"
fi
if [[ "${TARGET}1" == "all1" ]] || [[ "${TARGET}1" == "front1" ]] || [[ "${TARGET}1" == "fb1" ]]
then
echo
echo
echo "##############################################################"
echo "##############################################################"
echo "# FRONT END #"
echo "##############################################################"
echo "##############################################################"
echo
echo
#deploy front project
GCP/deploy_front.sh "${COUNTRY}" "${ENV}"
fi
if [[ "${TARGET}1" == "all1" ]] || [[ "${TARGET}1" == "functions1" ]]
then
echo
echo
echo "##############################################################"
echo "##############################################################"
echo "# CLOUD FUNCTIONS #"
echo "##############################################################"
echo "##############################################################"
echo
echo
#deploy back project
GCP/deploy_cloudFunctions.sh "${COUNTRY}" "${ENV}"
fi
if [[ "${TARGET}1" == "all1" ]] || [[ "${TARGET}1" == "route1" ]]
then
echo
echo
echo "##############################################################"
echo "##############################################################"
echo "# ROUTING TABLE #"
echo "##############################################################"
echo "##############################################################"
echo
echo
#deploy routing information
gcloud app deploy GCP/dispatch.yaml -q
fi