Created
August 21, 2018 18:03
-
-
Save sbalay/483b8bd33d19bfe2481b5036e13e242e to your computer and use it in GitHub Desktop.
Script to upload content to 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 | |
# $1 bucket-name | |
# $2 env | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[[:space:]]') | |
VERSION_DEPLOYMENT_URL="s3://$1/$2-$PACKAGE_VERSION" | |
# Create version folder | |
aws s3 sync build/ $VERSION_DEPLOYMENT_URL | |
aws s3 cp build/service-worker.js $VERSION_DEPLOYMENT_URL/service-worker.js --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate | |
aws s3 cp build/index.html $VERSION_DEPLOYMENT_URL/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate | |
# Replace content of the environment folder | |
aws s3 sync build/ s3://$1/$2 | |
aws s3 cp build/service-worker.js s3://$1/$2/service-worker.js --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate | |
aws s3 cp build/index.html s3://$1/$2/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment