Last active
April 10, 2019 06:26
-
-
Save mealies/768b6c95b39a5d35085595f09383c100 to your computer and use it in GitHub Desktop.
Deply hugo static site to AWS s3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
DISTRIBUTION_ID=E1TOB0026XX0U7 | |
BUCKET_NAME=thatopsguy.com | |
hugo -v | |
# Copy over pages | |
aws s3 sync --acl "public-read" --sse "AES256" public/ s3://$BUCKET_NAME/ --exclude 'img' --exclude 'js' --exclude 'css' --exclude 'post' | |
# Ensure static files are set to cache forever - cache for a month --cache-control "max-age=2592000" | |
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/img/ s3://$BUCKET_NAME/img/ | |
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/css/ s3://$BUCKET_NAME/css/ | |
aws s3 sync --cache-control "max-age=2592000" --acl "public-read" --sse "AES256" public/js/ s3://$BUCKET_NAME/js/ | |
# Invalidate landing page so everything sees new post. | |
aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths /index.html / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment