Files
data/scripts/deploy
T

30 lines
750 B
Bash
Executable File

#!/bin/bash
export AWS_CONFIG_FILE="aws.config"
ROOT="./data"
SITE="crafting-guide.com"
TARGET=""
while [[ "$1" != "" ]]; do
case "$1" in
"--staging") TARGET="staging";;
"--production") TARGET="production";;
esac
shift
done
if [[ "$TARGET" == "" ]]; then
echo "Please choose either --staging or --production for the target."
exit
fi
if [[ "$TARGET" == "staging" ]]; then
find "$ROOT" -name ".DS_Store" 2>/dev/null | xargs rm &>/dev/null
if grunt test; then
echo "Preparing to upload to S3..."
s3cmd sync -r --add-header="cache-control:max-age=1800" "$ROOT/" "s3://new.$SITE/data/"
fi
elif [[ "$TARGET" == "promote" ]]; then
aws s3 sync "s3://new.$SITE" "s3://$SITE" --delete
fi