scratch/tasks/ghpublish
Yann Esposito (Yogsototh) 796cd3f3e4 Added unsafe ghpublish
2012-04-11 01:31:01 +02:00

60 lines
1.4 KiB
Bash
Executable file

#!/usr/bin/env zsh
rootdir=$HOME/Sites/webroot
function log {
print -P -- $*
}
function debug {
# print -- $*
eval $*
}
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
# update & push gh-pages
log "Update and push gh-pages"
debug git co gh-pages
(( $? == 0 )) || { exit 1 }
debug git pull
(( $? == 0 )) || { exit 1 }
debug \rm -rf *(N)
(( $? == 0 )) || { exit 1 }
debug git co master output
(( $? == 0 )) || { exit 1 }
debug git unstage output
debug mv output/index.html .
(( $? == 0 )) || { exit 1 }
debug mv output/* .
(( $? == 0 )) || { exit 1 }
debug \rm -rf output
(( $? == 0 )) || { exit 1 }
debug cp Scratch/en/error/404-not_found/index.html 404.html
(( $? == 0 )) || { exit 1 }
debug echo "yannesposito.com" > CNAME
(( $? == 0 )) || { exit 1 }
debug git add .
(( $? == 0 )) || { exit 1 }
debug git commit -m '"updated website"'
(( $? == 0 )) || { exit 1 }
debug git push origin gh-pages:gh-pages
(( $? == 0 )) || { exit 1 }
debug git co $current_branch