-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·27 lines (26 loc) · 1.18 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
#!/bin/bash
if [ $1 = "data_viz_project_template" ]; then
echo "You need to specify your project name in package.json"
exit 1
else
echo "Your project directory: $1"
fi
for file in ./public/*
do
if [[ $file = *bundle.*.js ]]; then
rm "./public/bundle.js"
mv $file "./public/bundle.js"
aws s3 cp "./public/bundle.js" s3://datadotnewamerica/$1/bundle.js --cache-control "max-age=300"
elif [[ $file = *bundle.*.js.gz ]]; then
mkdir ./public/archive ./public/dist
cp $file ./public/archive/
aws s3 cp $file s3://datadotnewamerica/$1/archive/ --content-type "text/javascript" --content-encoding "gzip"
rm "./public/dist/bundle.js.gz"
mv $file ./public/dist/bundle.js.gz
aws s3 cp ./public/dist/bundle.js.gz s3://datadotnewamerica/$1/dist/bundle.js.gz --content-type "text/javascript" --content-encoding "gzip" --cache-control "max-age=300"
elif [[ $file = *index.html* ]]; then
aws s3 cp $file s3://datadotnewamerica/$1/index.html
fi
done
aws s3 sync ./src/images s3://datadotnewamerica/$1/images --exclude ./src/images/old
aws cloudfront create-invalidation --distribution-id E15K2IVEDI1Y6H --paths /$1/dist/bundle.js.gz /$1/bundle.js /$1/index.html