Last active
August 29, 2015 14:11
-
-
Save brouberol/14414c7b0944b4ad5a39 to your computer and use it in GitHub Desktop.
Git post-receive hook to build and deploy pelican blog
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
# The git user will run this script as a post-receive hook on the blog repository. | |
# It will build the latest version of the blog, and then copy it to the webserver directory | |
# This script is contained in the hooks/post-receive hook file of a git bare repository | |
# created with ``git init --bare``* | |
# We assume that pelican is installed globally, along with its dependencies. | |
BLOG_DIR=/var/www/blog | |
TMP_BLOG_CLONE=$HOME/blog-tmp | |
BLOG_GIT=/home/git/blog.git | |
# Pull the latest version of the code on a temporary, separate repo | |
git clone $BLOG_GIT $TMP_BLOG_CLONE | |
cd $TMP_BLOG_CLONE | |
# build the blog | |
make html | |
# copy it to the directory served by your webserver | |
# Note: the directory is both owned by www-data (user) and git (group) | |
# drwxrwxr-x 7 www-data git 4.0K Dec 8 21:43 blog | |
cp -r output/* $BLOG_DIR | |
# cleanup | |
cd .. | |
rm -rf $TMP_BLOG_CLONE | |
rm -rf $BLOG_DIR/.git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment