diff --git a/scripts/s3sync.sh b/scripts/s3sync.sh index a4904366..41fc5e3f 100755 --- a/scripts/s3sync.sh +++ b/scripts/s3sync.sh @@ -4,6 +4,17 @@ # Install awscli (pip install awscli) # Configure access credentials (aws configure), region is "eu-central-1" +# Usage: +# ./s3sync.sh DESTINATION SOURCE [clear] +# @DESTINATION: required, destination server +# @SOURCE: required, build +# @CLEAR: optional, delete previous uploads +# ./s3sync.sh stage beta +# ./s3sync.sh stage stable +# ./s3sync.sh stage stable clear +# ./s3sync.sh beta beta +# ./s3sync.sh stable stable + function confirm { read -r -p "Are you sure? [y/N] " response if [[ $response =~ ^(yes|y)$ ]]; then @@ -17,7 +28,7 @@ function confirm { # Validate params if [ "x$1" == "x" ] || [ "x$2" == "x" ]; then echo "Invalid params" - echo "./s3sync.sh beta|stable stage|beta|stable [clear]" + echo "./s3sync.sh stage|beta|stable beta|stable [clear]" exit 1 fi @@ -61,15 +72,15 @@ if [ "x$1" == "xbeta" ] || [ "x$1" == "xstable" ]; then confirm fi -# set -e -# cd `dirname $0` +set -e +cd `dirname $0` -# if [ "x$3" == "x-d" ]; then -# aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next -# else -# aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next -# fi +if [ "x$3" == "x-clear" ]; then + aws s3 sync --delete --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +else + aws s3 sync --cache-control 'public, max-age=3600' $SOURCE s3://$BUCKET/next +fi -# aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' +aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/next/*' echo "DONE" \ No newline at end of file