37 lines
798 B
Bash
37 lines
798 B
Bash
|
#!/usr/bin/env bash
|
||
|
|
||
|
set -euo pipefail
|
||
|
|
||
|
thisDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
rootDir="$(dirname "${thisDir}")"
|
||
|
|
||
|
main() {
|
||
|
SECONDS=0
|
||
|
echo "copying files to S3..."
|
||
|
aws s3 cp --recursive --acl public-read "${rootDir}/public/" s3://lucasfilmloom.com/
|
||
|
|
||
|
local distId
|
||
|
|
||
|
echo "querying for CloudFront distribution..."
|
||
|
distId=$(
|
||
|
aws cloudfront list-distributions \
|
||
|
--query "DistributionList.Items[?contains(Aliases.Items, 'lucasfilmloom.com')].Id | [0]" \
|
||
|
--output text
|
||
|
)
|
||
|
|
||
|
if [[ -z "${distId}" ]]; then
|
||
|
echo "failed to find cloudfront distribution"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
echo "found distribution \"${distId}\", invalidating CloudFront cache..."
|
||
|
|
||
|
aws cloudfront create-invalidation \
|
||
|
--distribution-id "${distId}" \
|
||
|
--paths '/*'
|
||
|
|
||
|
echo "all done in ${SECONDS}s"
|
||
|
}
|
||
|
|
||
|
main "$@"
|