Skip to content

Instantly share code, notes, and snippets.

@janklimo
Created August 9, 2019 09:00
Show Gist options
  • Save janklimo/de516d05a42dce5d3bf9084228c4cc33 to your computer and use it in GitHub Desktop.
Save janklimo/de516d05a42dce5d3bf9084228c4cc33 to your computer and use it in GitHub Desktop.
Publish client
#!/bin/sh
# Clean slate
echo "Cleaning up old assets and packs..."
rm -rf public/assets public/packs
# Precompile assets for production
echo "Precompiling assets..."
bundle exec rake assets:precompile RAILS_ENV=production PUBLISH_CLIENT=true
# Upload client JS
echo "Uploading client JS to S3..."
js_file_path=$(find ./public/packs/js -name "client-*.js")
aws s3 cp $js_file_path s3://awesome-gallery/js/client.js \
--cache-control "max-age=86400" \
--acl public-read
# Upload client CSS
echo "Uploading client CSS to S3..."
css_file_path=$(find ./public/assets -name "client-*.css")
aws s3 cp $css_file_path s3://awesome-gallery/css/client.css \
--cache-control "max-age=86400" \
--acl public-read
# Invalidate CDN cache
echo "Invalidating CDN cache..."
aws cloudfront create-invalidation --distribution-id E37OOSQGDX84GR --paths /js/* /css/*
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment