-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·51 lines (42 loc) · 1.57 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
#!/bin/bash
# ** Decide on the app name **
# If the calling process already set the APP_NAME env var then just use it
if [ -n "$APP_NAME" ]; then
echo "Using pre-set APP_NAME for app name"
# Otherwise if an argument was passed when this script was called then use that as the app name
elif [ "$#" -gt 0 ]; then
APP_NAME="$1"
# Otherwise use the local username as the app name suffix (THIS WON'T WORK ON WINDOWS - THERE IS NO SHORT USERNAME)
elif [ -n "$USER" ]; then
APP_NAME="cicada-${USER}"
# Otherwise fail
else
echo "Usage: ./deploy.sh APP_NAME, e.g. run \"./deploy.sh alice\" to deploy the cicada-alice app"
exit 1
fi
export APP_NAME
echo "APP_NAME set to ${APP_NAME}"
deployParams=("--" "--all")
# If calling process has set NO_HOTSWAP to anything, then DON'T hotswap, otherwise DO hotswap
# NB - don't use hotswap in production
if [ -z "$NO_HOTSWAP" ]; then
deployParams+=("--hotswap-fallback")
fi
# Bash settings to protect against various errors
set -euo pipefail
# ** START OF WEB BUILD **
rm -rf build/web
mkdir -p build/web
cp -rp src/web build/
# ** END OF WEB BUILD **
set +u
if [ -n "$ONLY_WEB_CONTENT" ]; then
BUCKET_NAME=$(aws cloudformation describe-stacks --stack-name $APP_NAME-main --query 'Stacks[0].Outputs[?OutputKey==`WebsiteBucketName`].OutputValue' --output text)
echo "Writing web content to bucket $BUCKET_NAME"
aws s3 sync build/web "s3://$BUCKET_NAME"
## NB / TOeventually - config.js won't be included here since directory deleted
## Consider not deleting build/web if ONLY_WEB_CONTENT set
else
npm run deploy "${deployParams[@]}"
fi
set -u