Created
December 29, 2008 22:01
-
-
Save wizardishungry/41407 to your computer and use it in GitHub Desktop.
GitHub post receive hook example -- secret support off
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php /* | |
example post receive hook for github | |
url: http://example.com/post-receive.php?secret=amazingpasswordgoeshere | |
setup sudo using visudo -- these are my defaults on openbsd, YMMV | |
Cmnd_Alias GIT = /usr/local/bin/git | |
Defaults:www !authenticate | |
www ALL=(usernamehere) NOPASSWD: GIT | |
*/ | |
$my_secret='amazingpasswordgoeshere'; | |
$my_path='/var/www/htdocs/example.com/'; | |
$my_user='usernamehere'; | |
$my_git='/usr/local/bin/git'; | |
function hide() | |
{ | |
header("Status: 404 Not Found"); | |
exit(); | |
} | |
if(!isset($_POST['payload'])) { hide(); } | |
//if(@$_GET['secret']!=$my_secret) { hide(); } | |
//$payload=json_decode($_POST['payload']); | |
echo shell_exec("cd $my_path && sudo -u $my_user $my_git pull"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment