public
Description: A Sinatra app that takes github's post-receive-hook and git pulls to the local repo.
Homepage: http://wiki.alcidesfonseca.com/hacks/git-pull-hook
Clone URL: git://github.com/alcides/git-pull-hook.git
name age message
file README.textile Tue Dec 30 04:58:32 -0800 2008 Just a small change in the readme. [alcides]
file git-pull-hook.rb Thu Apr 16 04:56:11 -0700 2009 Added brackets to the method headers(matter of ... [andhapp]
file repos.yml Mon Dec 08 06:33:42 -0800 2008 Example repos.yml improved [alcides]
README.textile

git-pull-hook

This is a Sinatra simple app that accepts POST requests from GitHub post-receive-hooks and performs a git pull origin master in the corresponding local git repository.

Work in Progress

This is just a quick and dirty hack, and it sure has security issues. I’d appreciate your feedback, please fork it and send me a pull-request in github.

Copyright and Legal Stuff

Who cares? This is under the WTFPL and it was originally coded by Alcides Fonseca

Short Guide

Well, first of all you need ssh access to a webserver where your copy of your github repo will live in.

Requirements:

  • Git (DUH!)
  • Ruby
  • gem install sinatra yaml json

Now you should ssh into the server and generate a public/private pair of keys, without pass-phrase: ssh-keygen

Now copy the content of your public key (cat .ssh/id_rsa.pub) and paste it as a new Deploy key in your github admin panel.

Now create a folder to host all your repositories. Mine is ~/git/ and save it for later. The clone your github repository.

Now you should deploy this sinatra app. Since I use dreamhost, I followed this instructions

Remember to edit repos.yml with the folder that host all your git repos, and the pair of remote: local repository names. (Probably the same.) Your remote name can be found in http://github.com/username/remote/ and your local name is the folder that contains your git repo.

Now go to Github admin panel, and add a new webhook service with the URL your sinatra app lives in.

And that’s it!