-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.bash
executable file
·38 lines (25 loc) · 1009 Bytes
/
upload.bash
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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "$SCRIPT_DIR/constants.env"
if [ "$#" -lt 1 ]; then
cat <<HEREDOC
Usage: $(basename ${BASH_SOURCE[0]}) <environment> <project> <directory-to-upload>
Deploys the given $APPLICATION environment
HEREDOC
exit 1
fi
PATH="$PATH:$SCRIPT_DIR/bin"
bucketKey="$2"
prefix=$(cut -d/ -f1 <<< "$bucketKey")
stackName="$1-$APPLICATION"
bucketName=$(get-stack-param "$stackName" StaticBucketName)
echo $bucketName
projects=("rex" "h5p" "analytics" "osano" "able-player" "quasar")
if [[ ! " ${projects[*]} " == *" ${prefix} "* ]]; then
echo "$prefix is not a recognized RAM project"
exit 1;
fi
aws s3 sync --delete "$3" "s3://${bucketName}/${bucketKey}" --region us-east-1
distributionId=$(get-stack-param "$stackName" DistributionId)
aws cloudfront create-invalidation --distribution-id "$distributionId" --paths "/${bucketKey}/*" --output text --query "Invalidation.Status"