Skip to content

Instantly share code, notes, and snippets.

@alasarr
Created April 24, 2018 11:52
Show Gist options
  • Save alasarr/0ba36a415a2da47aa54a40d8b25a4cd7 to your computer and use it in GitHub Desktop.
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
#!/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
@alasarr
Copy link
Author

alasarr commented Apr 24, 2018

Error page is set to index.html. The frontend application must manage this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment