Skip to content

Instantly share code, notes, and snippets.

@tusharf5
Created January 22, 2019 18:03
Show Gist options
  • Save tusharf5/53e7d00107c76650088ac8c9318b274f to your computer and use it in GitHub Desktop.
Save tusharf5/53e7d00107c76650088ac8c9318b274f to your computer and use it in GitHub Desktop.
Deploy to S3 Bucket with Cloudfront Invalidation
#!/bin/sh
echo "[Deploy] Building"
yarn run build
echo "[Deploy] Changing Directory"
cd ./dist
echo "[Deploy] Current Directory: ${PWD}"
echo "[Deploy] Emptying existing bucket <bucket_name>"
aws s3 rm s3://<bucket_name> --recursive
echo "[Deploy] Uploading new files to <bucket_name>"
aws s3 cp . s3://<bucket_name>/ --recursive
echo "[Deploy] Creating Invalidation for <bucket_name>"
aws cloudfront create-invalidation --distribution-id <cloudfront_distribution_id> --paths "/*"
echo "[Deploy] https://<bucket_name> updated."
@tusharf5
Copy link
Author

Don't forget to chmod +x ./deploy.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment