-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·69 lines (57 loc) · 2.09 KB
/
deploy.sh
File metadata and controls
executable file
·69 lines (57 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
#!/usr/bin/env bash
set -e
set -x
VAULT_TOKEN=$1
GIT_BRANCH=$2
TARGET_ENV=$3
set +x
if [ -z "$TARGET_ENV" ]; then
echo "TARGET_ENV argument not supplied; inferring from GIT_BRANCH '$GIT_BRANCH'."
if [ "$GIT_BRANCH" == "develop" ]; then
TARGET_ENV="dev"
elif [ "$GIT_BRANCH" == "alpha" ]; then
TARGET_ENV="alpha"
elif [ "$GIT_BRANCH" == "staging" ]; then
TARGET_ENV="staging"
elif [ "$GIT_BRANCH" == "master" ]; then
TARGET_ENV="prod"
else
echo "Git branch '$GIT_BRANCH' is not configured to automatically deploy to a target environment"
exit 1
fi
fi
if [[ "$TARGET_ENV" =~ ^(dev|alpha|staging|prod)$ ]]; then
ENVIRONMENT=${TARGET_ENV}
else
echo "Unknown environment: $TARGET_ENV - must be one of [dev, alpha, staging, prod]"
exit 1
fi
echo "Deploying branch '${GIT_BRANCH}' to ${ENVIRONMENT}"
set -x
GOOGLE_PROJECT=broad-avram-$ENVIRONMENT
docker pull ansingh7115/avram
# pull the credentials for the service account
docker run --rm -e VAULT_TOKEN=$VAULT_TOKEN broadinstitute/dsde-toolbox vault read --format=json "secret/dsde/avram/$ENVIRONMENT/deploy-account.json" | jq .data > deploy_account.json
# deploy endpoints
docker run \
-v $PWD:/app \
ansingh7115/avram /bin/bash -c \
"cd /app; gcloud auth activate-service-account --key-file=deploy_account.json && gcloud endpoints services deploy /app/openapi.yaml --project=$GOOGLE_PROJECT"
docker run -v $PWD:/app \
-e GOOGLE_PROJ=$GOOGLE_PROJECT \
-e SERVICE_VERSION=1 \
-e INPUT_PATH=/app \
-e OUT_PATH=/app/src/main/resources \
-e VAULT_TOKEN=$VAULT_TOKEN \
-e ENVIRONMENT=$ENVIRONMENT \
broadinstitute/dsde-toolbox render-templates.sh
# build app engine app
docker run \
-v $PWD:/app \
ansingh7115/avram /bin/bash -c \
"cd /app; APPENGINE_SDK_HOME=/home/gcloud/appengine-java-sdk-1.9.64 sbt package"
# deploy app engine app
docker run \
-v $PWD:/app \
ansingh7115/avram /bin/bash -c \
"/home/gcloud/appengine-java-sdk-1.9.64/bin/appcfg.sh --service_account_json_key_file=/app/deploy_account.json update /app/target/webapp"