Update upload script to mark compressed files
This commit is contained in:
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -e "./aws.config" ]]; then
|
||||
export AWS_CONFIG_FILE="./aws.config"
|
||||
else
|
||||
export AWS_CONFIG_FILE="$HOME/.aws/config"
|
||||
fi
|
||||
|
||||
ENVIRONMENT=""
|
||||
while [[ "$1" != "" ]]; do
|
||||
case "$1" in
|
||||
"--staging") ENVIRONMENT="staging";;
|
||||
"--production") ENVIRONMENT="production";;
|
||||
*) die "Please specify environment: --staging or --production";;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
SOURCE_DIR="./dist/"
|
||||
SITE="staging.crafting-guide.com"
|
||||
[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com"
|
||||
TARGET_DIR="s3://$SITE/"
|
||||
|
||||
S3CMD_CFG="$HOME/.s3cfg"
|
||||
echo "[default]" > "$S3CMD_CFG"
|
||||
cat $AWS_CONFIG_FILE | grep "aws_access_key_id" | sed "s/aws_access_key_id/access_key/" >> "$S3CMD_CFG"
|
||||
cat $AWS_CONFIG_FILE | grep "aws_secret_access_key" | sed "s/aws_secret_access_key/secret_key/" >> "$S3CMD_CFG"
|
||||
|
||||
HEADERS="--add-header=cache-control:max-age=1800"
|
||||
GZIP="--add-header=content-encoding:gzip"
|
||||
CMD="sync $SOURCE_DIR $TARGET_DIR -r -P $HEADERS --stop-on-error --exclude=*"
|
||||
|
||||
echo "Preparing to upload to S3..."
|
||||
s3cmd $CMD -m 'image/png' --include="*.png" || exit 1
|
||||
s3cmd $CMD $GZIP -m 'text/plain' --include="*.cg" || exit 1
|
||||
echo "S3 Upload Complete"
|
||||
Reference in New Issue
Block a user