Skip to content

Instantly share code, notes, and snippets.

@u8sand
Created November 9, 2016 18:05
Show Gist options
  • Save u8sand/403d899d073bec473ac8a582495f28fc to your computer and use it in GitHub Desktop.
Save u8sand/403d899d073bec473ac8a582495f28fc to your computer and use it in GitHub Desktop.
github.io-like Jekyll hook
#!/bin/bash
# Note that this goes under your github bare repo /hooks/
work=$(mktemp -d)
out=/http/
jekyll=/usr/share/ruby/2.3.0/bin/jekyll
while read oldrev newrev refname
do
branch=`echo $refname | cut -d/ -f3`
if [ "$branch" == "master" ]; then
GIT_WORK_TREE="$work" git checkout -f $branch
$jekyll build -s "$work" -d "$out"
find "$out" -type d -exec setfacl -m "g:http:r-x" {} +
find "$out" -type f -exec setfacl -m "g:http:r--" {} +
fi
done
rm -r "$work"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment