-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeploy.sh
executable file
·59 lines (46 loc) · 1.41 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
#!/usr/bin/env bash
BASEDIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
# resolve symlinks
while [ -h "$BASEDIR/$0" ]; do
DIR=$(dirname -- "$BASEDIR/$0")
SYM=$(readlink $BASEDIR/$0)
BASEDIR=$(cd $DIR && cd $(dirname -- "$SYM") && pwd)
done
cd ${BASEDIR}
app=sleepingPillCore
beanstalk_env=${1}
envs=$(eb list | sed 's/^\* //')
if [[ ${beanstalk_env} != ${app}-* ]]; then
echo "Usage: ${0} ${app}-<environment>"
echo
echo "Available environments:"
echo "${envs}"
exit 1
elif [ $(echo "${envs}" | grep "^${beanstalk_env}$" -c) -eq 0 ]; then
echo "Environment not recognized: '${beanstalk_env}'. Use one of the following:"
echo
echo "${envs}"
exit 1
fi
local_version=$( grep -E "<version>[0-9]+(\.[0-9]+).*(SNAPSHOT)?</version>" pom.xml -m1 2> /dev/null | sed 's/.*<version>\(.*\)<\/version>/\1/' )
version_suggestion="[${local_version}] "
read -p "Version? ${version_suggestion}" version
[ -z ${version} ] && version="${local_version}"
env=$(echo ${beanstalk_env} | sed s/${app}-//g)
trap "{ rm -f app.zip app.jar ${secret_properties_file} ; exit 255; }" EXIT
./package.sh ${env} ${version}
if [ $? -ne 0 ]; then
echo "> Package failed!"
exit 1
fi
if [ "${2}" == "debug" ]; then
echo "Debug mode. Skipping deploy."
rm -f app.zip
exit 0
fi
echo "> Deploying sleepingPillCore to ${beanstalk_env}"
eb deploy "${beanstalk_env}"
echo "> Deleting app.zip"
rm -f app.zip
echo "> Deploy complete.'"
exit 0