Created
April 24, 2018 11:52
-
-
Save alasarr/0ba36a415a2da47aa54a40d8b25a4cd7 to your computer and use it in GitHub Desktop.
Easy script to deploy a website in Google Cloud. It's optimized for Angular or any other HTML 5 application who manages URLs
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
#!/bin/bash | |
# CNAME -> c.storage.googleapis.com | |
bad_usage(){ | |
echo 'Bad parameters:' | |
echo "Usage: $0 <init|update> <domain> <folder_to_upload>" | |
exit 1 | |
} | |
init(){ | |
gsutil mb -l eu gs://${DOMAIN} | |
gsutil iam ch allUsers:objectViewer gs://${DOMAIN} | |
gsutil web set -m index.html -e index.html gs://${DOMAIN} | |
} | |
update(){ | |
gsutil rsync -r -d ${FOLDER} gs://${DOMAIN} | |
} | |
if [ $# -ne 3 ] ; then | |
bad_usage | |
exit 1 | |
fi | |
DOMAIN=$2 | |
FOLDER=$3 | |
OP=$1 | |
if [ "$OP" == "init" ]; then | |
init | |
update | |
elif [ "$OP" == "update" ]; then | |
update | |
else | |
bad_usage | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error page is set to index.html. The frontend application must manage this.