Created
November 2, 2012 20:19
-
-
Save seveas/4004079 to your computer and use it in GitHub Desktop.
Post receive publishing 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
#!/bin/bash | |
# | |
# Hook to copy the contents of a static blog generator to its final location. | |
# Publishing is now a matter of 'git push blog' | |
set -e | |
read oldrev newrev refname | |
if [ $refname = refs/heads/master ]; then | |
rev=$(echo $newrev | cut -c1-7) | |
if [ -e /srv/blog/$rev ]; then | |
echo "Already published" | |
exit 0 | |
fi | |
# Output is where the blog generator stores output. Copy it to a per-push | |
# directory and 'activate' it by pointing a symlink. | |
git archive HEAD:output/ --prefix $rev/ | (cd /srv/blog && tar -x) | |
chmod -R g+w /srv/blog/$rev | |
ln -snf $rev /srv/blog/current | |
echo "Published blog on http://blog......com" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment