Created
November 16, 2010 06:47
-
-
Save mjangda/701537 to your computer and use it in GitHub Desktop.
Quick and dirty script that can auto-pull to keep your repo up-to-date any time something is pushed to the remote repo
This file contains hidden or 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 | |
// Edit these to match your environment settings | |
define( 'BASE_PATH', '/home/username/webapps' ); | |
// This is the path to the git executable | |
define( 'GIT_PATH', get_full_path( '/git/bin/git' ) ); | |
// Edit this array so the key matches the github repo name and the value is path of the repo relative to the BASE_PATH | |
$repository_paths = array( | |
'test' => '/git-test' | |
); | |
if( isset( $_POST['payload'] ) ) { | |
$payload = json_decode( stripslashes( $_POST['payload'] ) ); | |
if( isset( $repository_paths[ $payload->repository->name ] ) ) { | |
$path = get_full_path( $repository_paths[ $payload->repository->name ] ); | |
$cmd = sprintf( 'cd %s; ', $path ); | |
$cmd .= sprintf( '%s pull', GIT_PATH ); | |
shell_exec( $cmd ); | |
die( "Executed: $cmd!" ); | |
} | |
} | |
die( 'Dont\'t think you\'re sposed to be here...' ); | |
function get_full_path( $path ) { | |
return BASE_PATH . $path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Written for my setup on Webfaction so it's unlikely to work as-is for others. You likely have to tweak the base and git paths.