-
-
Save Irfan-Ansari/9505378 to your computer and use it in GitHub Desktop.
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