scratch/tasks/ghpublish

57 lines
1.2 KiB
Text
Raw Normal View History

2011-04-20 13:09:17 +00:00
#!/usr/bin/env zsh
rootdir=$HOME/Sites/webroot
2011-04-20 14:28:44 +00:00
function log {
print -P -- $*
}
2011-04-20 13:38:41 +00:00
function debug {
2012-06-15 13:53:26 +00:00
print -- $*
2011-04-20 13:38:41 +00:00
eval $*
2012-06-15 14:03:46 +00:00
(( $? == 0 )) || { exit 1 }
2011-04-20 13:38:41 +00:00
}
current_branch=$(git branch | egrep '^\*' | awk '{print $2}')
2011-04-20 13:09:17 +00:00
cd $rootdir || { print -- "Unable to go to $HOME/Sites/webroot"; exit 1 }
git co master || { exit 1 }
git pull || { exit 1 }
2012-04-10 23:31:01 +00:00
if [[ $1 = '--unsafe' ]]; then
log "UNSAFE no compilation"
else
# empty regen depencies cache because of a bug
\rm -f ./tmp/*(N)
./tasks/recompile
fi
2011-04-20 13:09:17 +00:00
if git status | grep 'nothing to commit'>/dev/null 2>&1; then
else
git add .
git commit -m "regeneration"
fi
2012-06-15 14:03:46 +00:00
log "tar creation"
ghroot=/tmp/ghroot$$
mkdir $ghroot
debug mv output/index.html $ghroot
debug mv output/* $ghroot
debug cd $ghroot
2012-06-15 14:05:55 +00:00
debug cp Scratch/en/error/404-not_found/index.html ./404.html
2012-06-15 14:23:48 +00:00
echo "yannesposito.com" > CNAME
2012-06-15 14:03:46 +00:00
debug tar cf ghroot.tar *
debug cd $rootdir
2011-04-20 13:09:17 +00:00
# update & push gh-pages
2011-04-20 14:28:44 +00:00
log "Update and push gh-pages"
2011-04-20 13:38:41 +00:00
debug git co gh-pages
2011-04-20 14:18:30 +00:00
debug git pull
2012-06-15 14:03:46 +00:00
debug \rm -rf *(N)
debug tar xf $ghroot/ghroot.tar
2011-04-20 13:38:41 +00:00
debug git add .
debug git commit -m '"updated website"'
2011-04-20 13:46:13 +00:00
debug git push origin gh-pages:gh-pages
debug git co $current_branch
2012-06-15 14:03:46 +00:00
2012-06-15 14:15:11 +00:00
# rm -rf $ghroot