#!/bin/sh

# post-receive hook for the webserver

TARGET="/var/www/htdocs/slimegirl.nexus"
GIT_DIR="/var/www/pub/git/slimegirl.nexus"

cleanup() { rm -rf "$tmpdir"; }

trap cleanup EXIT

while read oldrev newrev ref; do
    if [ "$ref" == "refs/heads/master" ]; then
	tmpdir=$(mktemp -d)
	cd $tmpdir
	git --work-tree=. --git-dir="$GIT_DIR" checkout -f
	gmake compress
	rsync -rcvP --delete out/ "$TARGET"
    fi
done

