-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdeploy.sh
executable file
·81 lines (70 loc) · 2.51 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
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
source $(dirname "$0")/init.sh
PREFIX=
BUILD_TYPE=deploy
NOBUILD=0
IMAGE_NAME=
STACK_NAME=${STACK_NAME:-"$APP_DIR_NAME"}
AWS_CF_DEPLOY_OPTS=${AWS_CF_DEPLOY_OPTS:-""}
while [ $# -ne 0 ]; do
case "$1" in
--no-build)
NOBUILD=1; shift;
;;
--build-type)
shift
if [ -n "$1" ] && [ ${1:0:1} != "-" ]; then BUILD_TYPE=$1; shift; else err "missing build type with --build-type"; fi
;;
-t)
shift
if [ -n "$1" ] && [ ${1:0:1} != "-" ]; then IMAGE_NAME=$1; shift; else err "missing image name with -t"; fi
;;
-p)
shift
if [ -n "$1" ] && [ ${1:0:1} != "-" ]; then PREFIX=$1; shift; else err "missing prefix with -p"; fi
;;
-n)
shift
if [ -n "$1" ] && [ ${1:0:1} != "-" ]; then STACK_NAME=$1; shift; else err "missing stack name with -n"; fi
;;
*)
err "invalid option $1"
;;
esac
done
if [ $NOBUILD -eq 0 ]; then
ORIG_PREFIX=
if [ -n "$PREFIX" ]; then
ORIG_PREFIX="$PREFIX"
fi
source $(dirname "$0")/vars.sh
PREFIX_ARG=""
if [ -n "$ORIG_PREFIX" ]; then PREFIX_ARG="-p $ORIG_PREFIX"; fi
if [ -z "$IMAGE_NAME" ]; then
P_IMAGE_NAME=${PREFIX}IMAGE_NAME
IMAGE_NAME=${!P_IMAGE_NAME:-$APP_DIR_NAME}
fi
$SCRIPT_DIR/build.sh -t "$IMAGE_NAME" --full --push --build-type $BUILD_TYPE $PREFIX_ARG
else
source $(dirname "$0")/vars.sh
fi
println "\n%s" "-- DEPLOY ----------------------------------------------------------------------"
println "Root directory: $ROOT_DIR"
println "App directory: $APP_DIR"
println "AWS region: $AWS_REGION"
println "Prefix: $PREFIX"
println "Build type: $BUILD_TYPE"
println "No build: $NOBUILD"
println "Stack Name: $STACK_NAME"
println "Deploy stack options: $AWS_CF_DEPLOY_OPTS"
println "%s\n" "--------------------------------------------------------------------------------"
printf "Deploying stack $STACK_NAME...\n"
aws cloudformation deploy \
--stack-name $STACK_NAME \
--template-file $APP_DIR/deploy/cf-template.yaml \
--output table \
--no-cli-pager \
--color on \
--parameter-overrides file://$APP_DIR/deploy/cf-params.$BUILD_TYPE.json \
$AWS_CF_DEPLOY_OPTS
println "Done."