Created
September 20, 2018 20:24
-
-
Save igolden/4c6f1fa6c0a53c1ac6b447d0c9015116 to your computer and use it in GitHub Desktop.
Deploy an s3 website easily
This file contains hidden or 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
set -e; | |
# Options | |
#====================================== | |
# Warnings cause build failures | |
# if CI=true. | |
export CI=false | |
PROFILE=default | |
BUCKET_NAME=example | |
#======================================= | |
# Color Setup | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' | |
#======================================= | |
# display error if exit | |
handle_error() { | |
echo -e "${RED}DEPLOY FAILED - VIEW LOGS" | |
} | |
trap 'handle_error $LINENO' ERR | |
echo -e "${YELLOW}Running production build command..${NC}" | |
if [ "$1" == "-q" ]; then | |
yarn build &> /dev/null | |
else | |
yarn build | |
fi | |
echo -e "${GREEN}Done!${NC}" | |
cd build | |
echo -e "${YELLOW}Uploading to S3 Bucket '$BUCKET_NAME'...${NC}" | |
if [ "$1" == "-q" ]; then | |
aws s3 cp --recursive . s3://$BUCKET_NAME &> /dev/null | |
else | |
aws s3 cp --recursive . s3://$BUCKET_NAME | |
fi | |
cd .. | |
echo -e "${GREEN}Success!${NC} View the project at: \nhttp://$BUCKET_NAME.s3-website-$REGION.amazonaws.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment