Skip to content

PHP script to respond to git hooks and does a pull command when a specified branch is updated. Then emails will be sent to committer to know that the server has their changes now.

Notifications You must be signed in to change notification settings

rlorenzo/track-branch-via-git-hooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tracking branch via git hooks

References 
http://help.github.com/post-receive-hooks/
http://blog.badsyntax.co/post/3014159260/github-web-hook-post-receive

This script will respond to the JSON that github sends after a commit in a repo.
Then it will look at the branch that a commit was made and if it is a specified
branch the script will then perform a sudo to do a request pull as a specified
user for a specified local git repo.

Then the git pusher and specified admin will receive an email with the output
of the git pull and some details from the commit.

Installation

1) To use script, put it in a web accessible directory.
2) Copy/rename config.php.dist to config.php
3) Set appropiate values for config.php
4) Setup your github repo to point to this script as your post-receive hook 
   server as mentioned here: http://help.github.com/post-receive-hooks/
5) Setup apache user to run gitpull.php script has specified user. Edit sudoer 
   file with:
   apache ALL = (<USER>) NOPASSWD: <PATH_TO_SCRIPT>/gitpull.php
6) Make sure that your sudoers file has "Default requiretty" commented out, so
   that the apache user can sudo and run a string as a different user:
   http://www.zimbra.com/forums/installation/10553-solved-sudo-sorry-you-must-have-tty-run-sudo.html

About

PHP script to respond to git hooks and does a pull command when a specified branch is updated. Then emails will be sent to committer to know that the server has their changes now.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages