-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-deploy.sh
executable file
·56 lines (50 loc) · 1.96 KB
/
build-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
#!/bin/bash
# first parameter: environment to deploy to (front | testing)
#immediately exits if a command exits with an non-zero status
set -e
# build the project (contents will be in directory dist/bms-front)
echo "Build starting"
if [[ $1 == "front" ]]; then
npm run build -- --prod --progress
elif [[ $1 == "testing" ]]; then
npm run build -- --prod -c testing --progress
elif [[ $1 == "demo" ]]; then
npm run build -- --prod -c demo --progress
else
echo "Unknown environment"
exit
fi
echo "Build complete"
# gzip up all files so that they are smaller
echo "Compression starting"
rm -Rf dist/bms-front_gzip/
cp -R dist/bms-front/ dist/bms-front_gzip/
gzip -9fr dist/bms-front_gzip/
FILES=`find dist/bms-front_gzip`
for FILE in $FILES; do
NEW_FILE=${FILE/.gz/}
echo $NEW_FILE
if [ "${FILE}" != "${NEW_FILE}" ]; then
mv ${FILE} ${NEW_FILE}
fi;
done;
echo "Compression complete"
# deploy on aws
echo "Upload starting"
aws configure set aws_access_key_id ${aws_access_key_id}
aws configure set aws_secret_access_key ${aws_secret_access_key}
aws configure set default.region eu-central-1
if [[ $1 == "front" ]]; then
aws s3 rm s3://front.bmstaging.info --recursive
aws s3 cp ./dist/bms-front_gzip s3://front.bmstaging.info --recursive --acl public-read --content-encoding gzip
aws cloudfront create-invalidation --distribution-id E2CS9FD9XA4VY8 --paths '/*'
elif [[ $1 == "testing" ]]; then
aws s3 rm s3://testing.bmstaging.info --recursive
aws s3 cp ./dist/bms-front_gzip s3://testing.bmstaging.info --recursive --acl public-read --content-encoding gzip
aws cloudfront create-invalidation --distribution-id E1FDBGHL3DD0Y8 --paths '/*'
elif [[ $1 == "demo" ]]; then
aws s3 rm s3://demo.humansis.org --recursive
aws s3 cp ./dist/bms-front_gzip s3://demo.humansis.org --recursive --acl public-read --content-encoding gzip
aws cloudfront create-invalidation --distribution-id EETRVGJ9FHCMD --paths '/*'
fi
echo "Upload complete"