Update build with changes from crafting-guide.com

This commit is contained in:
Andrew Miner
2016-04-03 21:50:52 -07:00
parent 3ae13b5acd
commit c5012e8b5b
4 changed files with 99 additions and 53 deletions
+17 -21
View File
@@ -6,35 +6,31 @@ else
export AWS_CONFIG_FILE="$HOME/.aws/config"
fi
SOURCE_DIR="./data/"
SITE="crafting-guide.com"
TARGET=""
ENVIRONMENT=""
while [[ "$1" != "" ]]; do
case "$1" in
"--staging") TARGET="staging";;
"--production") TARGET="production";;
"--staging") ENVIRONMENT="staging";;
"--production") ENVIRONMENT="production";;
*) die "Please specify environment: --staging or --production";;
esac
shift
done
if [[ "$TARGET" == "" ]]; then
echo "Please choose either --staging or --production for the target."
exit 1
fi
if [[ "$TARGET" == "staging" ]]; then
TARGET_DIR="s3://new.$SITE/data/"
elif [[ "$TARGET" == "production" ]]; then
TARGET_DIR="s3://$SITE/data/"
fi
SOURCE_DIR="./dist/"
SITE="staging.crafting-guide.com"
[[ "$ENVIRONMENT" == "production" ]] && SITE="crafting-guide.com"
TARGET_DIR="s3://$SITE/"
S3CMD_CFG="$HOME/.s3cfg"
if [[ ! -e "$S3CMD_CFG" ]]; then
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"
fi
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 sync -r -P --add-header="cache-control:max-age=1800" $SOURCE_DIR $TARGET_DIR
s3cmd $CMD -m 'image/png' --include="*.png" || exit 1
s3cmd $CMD $GZIP -m 'text/plain' --include="*.cg" || exit 1
echo "S3 Upload Complete"