7th-saga/scripts/deploy.sh

37 lines
817 B
Bash
Raw Permalink Normal View History

2021-08-26 18:31:53 +00:00
#!/usr/bin/env bash
set -euo pipefail
readonly thisDir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly rootDir="$(dirname "${thisDir}")"
main() {
SECONDS=0
echo "copying files to S3..."
aws s3 cp --recursive --acl public-read "${rootDir}/scraped/" s3://7thsaga.tmont.com/
local distId
echo "querying for CloudFront distribution..."
distId=$(
aws cloudfront list-distributions \
--query "DistributionList.Items[?contains(Aliases.Items, '7thsaga.tmont.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 "$@"