#!/bin/sh
# Yaroslav de la Peña Smirnov <yps@yaroslavps.com>

#####################################################
#		Copy me to the hooks subdirectory! 			#
# 	git hook to update my site on push to master	#
#####################################################


oldpwd="$PWD"
reponame="yaroslavps.com"
barepath="$HOME/public/$reponame.git"
workingpath="$HOME/hook-clones/$reponame"

while read LINE; do
	if [ "$(echo ${LINE} | awk '{ print $3; }')" = "refs/heads/master" ]
	then
		cd "$HOME/hook-clones"
		git clone $barepath
		cd $reponame
		zola build --output-dir="/home/webuser/www/yaroslavps.com/"
		cd ..
		rm -rf "$reponame"
		exit 0
	fi
done