Created
April 7, 2011 06:32
-
-
Save akheron/907157 to your computer and use it in GitHub Desktop.
How to generate a stango website in git post-receive hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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