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