Created
December 18, 2014 21:20
-
-
Save jodoherty/1fb44d3eb01d905cc2ce to your computer and use it in GitHub Desktop.
Middleman S3 deployment script using aws cli tools
This file contains hidden or 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/sh | |
BUCKET="james-odoherty.com" | |
set -e | |
bundle exec middleman build | |
find ./build \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' -o -iname '*.txt' \) -exec gzip -9 -n {} \; -exec mv {}.gz {} \; | |
aws s3 rm s3://$BUCKET --recursive | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=1576800000" --exclude "*.html" --exclude "*.css" --exclude "*.js" --exclude "*.txt" | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=0, no-cache" --content-type='application/javascript' --content-encoding='gzip' --exclude "*" --include "*.js" | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=0, no-cache" --content-type='text/css' --content-encoding='gzip' --exclude "*" --include "*.css" | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=0, no-cache" --content-type='text/html' --content-encoding='gzip' --exclude "*" --include "*.html" | |
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=0, no-cache" --content-type='text/plain' --content-encoding='gzip' --exclude "*" --include "*.txt" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment