-
Notifications
You must be signed in to change notification settings - Fork 11
/
package.sh
executable file
·55 lines (44 loc) · 1.53 KB
/
package.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
#!/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}
if [ -z ${1} ] || [ -z ${2} ]; then
echo "Usage: ${0} <env> <version>"
exit 1
fi
app=cake-redux
env=${1}
version=${2}
echo "> Assembling files"
secret_properties_file="config.properties"
ansible-vault decrypt "config/prod.properties.encrypted" --output=${secret_properties_file}
if [ ! -f ${secret_properties_file} ]; then
echo "Something went wrong with decrypting secret properties. File ${secret_properties_file} is missing. Can't deploy..."
exit 1
fi
authorization_file=cakeauthorized.txt
ansible-vault decrypt "config/cakeauthorized.prod.encrypted" --output=${authorization_file}
if [ ! -f ${secret_properties_file} ]; then
echo "Something went wrong with decrypting secret properties. File ${authorization_file} is missing. Can't deploy..."
exit 1
fi
cp ~/.m2/repository/no/javazone/${app}/${version}/${app}-${version}-jar-with-dependencies.jar ./app.jar
if [ $? -ne 0 ]; then
rm -f ${secret_properties_file}
exit 1
fi
echo "> Packaging app"
chmod 644 ${secret_properties_file}
zip -r app.zip app.jar .ebextensions Procfile ${secret_properties_file} ${authorization_file}
if [ $? -ne 0 ]; then
rm -f app.jar ${secret_properties_file}
echo "> Package failed!"
exit 1
fi
rm -f app.jar ${secret_properties_file} ${authorization_file}
echo "> Done packaging app"