Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Publish client
# 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