forked from m-lab/mlab-vis-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·70 lines (59 loc) · 1.57 KB
/
deploy.sh
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
#!/bin/bash
set -e
set -x
usage() {
echo "Usage: KEY_FILE=<path> $0 -m staging|production|sandbox" $1 1>&2; exit 1;
}
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ -n "${API_MODE}" ]; then
source $DIR/environments/$API_MODE.sh
cp $DIR/environments/$API_MODE.sh .env
else
while getopts ":m:" opt; do
case $opt in
m)
echo "${OPTARG} environment"
if [[ "${OPTARG}" == production ]]; then
source $DIR/environments/production.sh
cp $DIR/environments/production.sh .env
elif [[ "${OPTARG}" == staging ]]; then
source $DIR/environments/staging.sh
cp $DIR/environments/staging.sh .env
elif [[ "${OPTARG}" == sandbox ]]; then
source $DIR/environments/sandbox.sh
cp $DIR/environments/sandbox.sh .env
else
echo "BAD ARGUMENT TO $0: ${OPTARG}"
exit 1
fi
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
fi
# build app.yaml
mkdir -p deploy-build
cp templates/app.yaml deploy-build/
./travis/substitute_values.sh deploy-build/ \
APIROOT ${APIROOT} \
API_MODE ${API_MODE} \
NODE_PATH ${NODE_PATH} \
NODE_ENV ${NODE_ENV} \
PORT ${PORT}
cp deploy-build/app.yaml app.yaml
# authenticate
gcloud config set project ${PROJECT}
gcloud auth activate-service-account --key-file=${KEY_FILE}
# deploy
gcloud app deploy
# clean up
rm app.yaml
rm -rf deploy-build
rm .env