Permalink
Browse files

`jekyll build` service hook listener

…in bash with netcat…
  • Loading branch information...
kjell committed Jan 11, 2014
1 parent 0116b01 commit 2195fd286419c898874edf079497035cbeeefaa6
Showing with 75 additions and 0 deletions.
  1. +3 −0 _hook/Gemfile
  2. +51 −0 _hook/Gemfile.lock
  3. +2 −0 _hook/Makefile
  4. +19 −0 _hook/hook.sh
View
@@ -0,0 +1,3 @@
source "https://rubygems.org"
gem 'jekyll'
View
@@ -0,0 +1,51 @@
GEM
remote: https://rubygems.org/
specs:
blankslate (2.1.2.4)
classifier (1.3.4)
fast-stemmer (>= 1.0.0)
colorator (0.1)
commander (4.1.5)
highline (~> 1.6.11)
fast-stemmer (1.0.2)
ffi (1.9.3)
highline (1.6.20)
jekyll (1.4.2)
classifier (~> 1.3)
colorator (~> 0.1)
commander (~> 4.1.3)
liquid (~> 2.5.2)
listen (~> 1.3)
maruku (~> 0.7.0)
pygments.rb (~> 0.5.0)
redcarpet (~> 2.3.0)
safe_yaml (~> 0.9.7)
toml (~> 0.1.0)
liquid (2.5.4)
listen (1.3.1)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
maruku (0.7.0)
parslet (1.5.0)
blankslate (~> 2.0)
posix-spawn (0.3.8)
pygments.rb (0.5.4)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
redcarpet (2.3.0)
safe_yaml (0.9.7)
toml (0.1.0)
parslet (~> 1.5.0)
yajl-ruby (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
jekyll
View
@@ -0,0 +1,2 @@
bundle:
bundle install --path bundle --binstubs
View
@@ -0,0 +1,19 @@
echo "starting hook: " $port " -- " $dest " -- " $branch
[[ -e _pipe ]] && rm _pipe
mkfifo _pipe
while true; do
{
# block until netcat recieves a request and sends it to `_pipe`
read input < _pipe
# only accept requests from github // "The Public IP addresses for these hooks are: 192.30.252.0/22"
if echo $input | egrep -q "192\.30\.252\.[0-255]"; then
echo $input >&2 # now do stuff
git checkout $branch
git fetch
git reset --hard origin/$branch >&2
./_hook/bin/jekyll build -d $dest >&2
echo -e "HTTP/1.1 200 OK\r\n"
fi
} | nc -v -l $port &> _pipe
done

0 comments on commit 2195fd2

Please sign in to comment.