vgtiler-crystalis/scripts/deploy.sh

37 lines
806 B
Bash
Executable File

#!/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://crystalis.vgtiler.com/
local distId
echo "querying for CloudFront distribution..."
distId=$(
aws cloudfront list-distributions \
--query "DistributionList.Items[?contains(Aliases.Items, 'crystalis.vgtiler.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 "$@"