#!/usr/bin/env zsh rootdir=$HOME/Sites/webroot function log { print -P -- $* } function debug { print -- $* eval $* (( $? == 0 )) || { exit 1 } } current_branch=$(git branch | egrep '^\*' | awk '{print $2}') cd $rootdir || { print -- "Unable to go to $HOME/Sites/webroot"; exit 1 } git co master || { exit 1 } git pull || { exit 1 } if [[ $1 = '--unsafe' ]]; then log "UNSAFE no compilation" else # empty regen depencies cache because of a bug \rm -f ./tmp/*(N) ./tasks/recompile fi if git status | grep 'nothing to commit'>/dev/null 2>&1; then else git add . git commit -m "regeneration" fi log "tar creation" ghroot=/tmp/ghroot$$ mkdir $ghroot debug mv output/index.html $ghroot debug mv output/* $ghroot debug cd $ghroot debug cp Scratch/en/error/404-not_found/index.html ./404.html echo "yannesposito.com" > CNAME debug tar cf ghroot.tar * debug cd $rootdir # update & push gh-pages log "Update and push gh-pages" debug git co gh-pages debug git pull debug \rm -rf *(N) debug tar xf $ghroot/ghroot.tar debug git add . debug git commit -m '"updated website"' debug git push origin gh-pages:gh-pages debug git co $current_branch # rm -rf $ghroot