github.com/jsoriano/terraform@v0.6.7-0.20151026070445-8b70867fdd95/scripts/website_push.sh (about) 1 #!/bin/bash 2 3 # Set the tmpdir 4 if [ -z "$TMPDIR" ]; then 5 TMPDIR="/tmp" 6 fi 7 8 # Create a temporary build dir and make sure we clean it up. For 9 # debugging, comment out the trap line. 10 DEPLOY=`mktemp -d $TMPDIR/terraform-www-XXXXXX` 11 trap "rm -rf $DEPLOY" INT TERM EXIT 12 13 # Get the parent directory of where this script is. 14 SOURCE="${BASH_SOURCE[0]}" 15 while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done 16 DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" 17 18 # Copy into tmpdir 19 shopt -s dotglob 20 cp -r $DIR/website/* $DEPLOY/ 21 22 # Change into that directory 23 pushd $DEPLOY &>/dev/null 24 25 # Ignore some stuff 26 touch .gitignore 27 echo ".sass-cache" >> .gitignore 28 echo "build" >> .gitignore 29 echo "vendor" >> .gitignore 30 31 # Add everything 32 git init -q . 33 git add . 34 git commit -q -m "Deploy by $USER" 35 36 git remote add heroku git@heroku.com:terraform-www.git 37 git push -f heroku master 38 39 # Go back to our root 40 popd &>/dev/null