Skip to content

Instantly share code, notes, and snippets.

@seveas
Created March 30, 2015 19:06
Show Gist options
  • Save seveas/35a86ee2b0ba7a9ad24c to your computer and use it in GitHub Desktop.
Save seveas/35a86ee2b0ba7a9ad24c to your computer and use it in GitHub Desktop.
[dkaarsemaker@blog-001 ~]$ cat /srv/blog/blog.git/hooks/post-receive
#!/bin/bash
BLOG_PATH="/srv/blog";
REPO_PATH="${BLOG_PATH}/blog.git/";
WWW_PATH="${BLOG_PATH}/current";
CURRENT_SHA1=`cat ${REPO_PATH}/refs/heads/master`;
PUBLISH_DIR="${BLOG_PATH}/${CURRENT_SHA1}";
WORK_DIR="${PUBLISH_DIR}_workdir"
mkdir ${WORK_DIR};
git --git-dir=${REPO_PATH} --work-tree=${WORK_DIR} checkout -f master
cp -a "${WORK_DIR}/output" ${PUBLISH_DIR}
ln -snf ${PUBLISH_DIR} ${WWW_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment