forked from ocadotechnology/codeforlife-deploy-appengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·52 lines (36 loc) · 1.66 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
#!/bin/bash -ex
export CLOUDSDK_CORE_DISABLE_PROMPTS=1
export CLOUDSDK_PYTHON_SITEPACKAGES=1
GCLOUD=${SEMAPHORE_CACHE_DIR}/google-cloud-sdk/bin/gcloud
if [ ! -x ${GCLOUD} ]; then
wget https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-159.0.0-linux-x86_64.tar.gz
tar zxf google-cloud-sdk-159.0.0-linux-x86_64.tar.gz -C ${SEMAPHORE_CACHE_DIR}
rm google-cloud-sdk-159.0.0-linux-x86_64.tar.gz
fi
${GCLOUD} --quiet components update
${GCLOUD} auth activate-service-account --key-file .gcloud-key
export MODULE_NAME=$1
export VERSION="$2"
export DATABASE_POSTFIX="$3"
export DATABASE_NAME="cfl_${DATABASE_POSTFIX}"
export CACHE_PREFIX="${MODULE_NAME}-${VERSION}-"
export GOOGLE_APPLICATION_CREDENTIALS=/home/runner/codeforlife-deploy-appengine/.gcloud-key
# Install the dependencies for the following deploy script.
# Kubernetes is a TEMPORARY solution. See issue 68.
pip install kubernetes==5.0.0
pip install pyyaml
# Authenticate the cluster by updating kubeconfig.
${GCLOUD} config set project ${APP_ID}
${GCLOUD} container clusters get-credentials ${MODULE_NAME} --zone europe-west1-b
# Deploy the correct kubernetes cluster.
python clusters_setup/deploy.py "${MODULE_NAME}"
./manage.py migrate --no-input
envsubst <app.yaml.tmpl >app.yaml
${GCLOUD} app --quiet deploy app.yaml --project ${APP_ID} --version ${VERSION} --no-promote
${GCLOUD} app --quiet deploy cron.yaml --project ${APP_ID} --version ${VERSION} --no-promote
# Test the site
./test.sh ${MODULE_NAME} ${VERSION}
# Promote
${GCLOUD} app services set-traffic --project ${APP_ID} --splits ${VERSION}=1 ${MODULE_NAME} --migrate
# Test the site - again!
./test.sh ${MODULE_NAME} default