Skip to content

Instantly share code, notes, and snippets.

@akheron
Created April 7, 2011 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akheron/907157 to your computer and use it in GitHub Desktop.
Save akheron/907157 to your computer and use it in GitHub Desktop.
How to generate a stango website in git post-receive hook
# Git repository configuration for a detached worktree.
#
# Create a bare repository:
#
# $ git init --bare
#
# Then change the config to match this file.
[core]
repositoryformatversion = 0
filemode = true
bare = false
worktree = /path/to/detached/worktree
[receive]
denycurrentbranch = ignore
#!/bin/sh
SRC="/path/to/detached/worktree"
DEST="/var/www"
BRANCH="master"
STANGO="/path/to/stango"
# If you're using virtualenv
. /path/to/virtualenv/bin/activate
REF="refs/heads/$BRANCH"
set -e
while read old new ref; do
if [ "$ref" = "$REF" ]; then
updated=1
fi
done
[ -z "$updated" ] && exit
echo "Building..."
exec >/dev/null
git checkout -f
git clean -f -d -x
cd $SRC
PYTHONPATH=$STANGO $STANGO/bin/stango generate out
# Use rsync -c to only copy modified files, --del to delete files that don't exist anymore.
rsync -c --del out/ $DEST/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment