From 8f727219d991f230c2832e80d08c2a4d30ab7a32 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Thu, 8 Oct 2015 13:50:50 -0400 Subject: [PATCH] Use a faster deploy script --- scripts/website_push.sh | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/website_push.sh b/scripts/website_push.sh index fafcbd70c..95168f977 100755 --- a/scripts/website_push.sh +++ b/scripts/website_push.sh @@ -1,12 +1,40 @@ #!/bin/bash +# Set the tmpdir +if [ -z "$TMPDIR" ]; then + TMPDIR="/tmp" +fi + +# Create a temporary build dir and make sure we clean it up. For +# debugging, comment out the trap line. +DEPLOY=`mktemp -d $TMPDIR/packer-www-XXXXXX` +trap "rm -rf $DEPLOY" INT TERM EXIT + # Get the parent directory of where this script is. SOURCE="${BASH_SOURCE[0]}" while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" -# Change into that directory -cd $DIR +# Copy into tmpdir +shopt -s dotglob +cp -r $DIR/website/* $DEPLOY/ -# Push the subtree (force) -git push heroku `git subtree split --prefix website master`:master --force +# Change into that directory +pushd $DEPLOY &>/dev/null + +# Ignore some stuff +touch .gitignore +echo ".sass-cache" >> .gitignore +echo "build" >> .gitignore +echo "vendor" >> .gitignore + +# Add everything +git init -q . +git add . +git commit -q -m "Deploy by $USER" + +git remote add heroku git@heroku.com:packer-www.git +git push -f heroku master + +# Go back to our root +popd &>/dev/null