Create a gist now

Instantly share code, notes, and snippets.

@rahul286 /hook.php
Last active Dec 17, 2015

What would you like to do?
<?php
$repos['my-repo'] = array (
"path" => "/var/www/example.com/htdocs/wp-content/plugins/my-repo" ,
"branch" => "master"
);
$repos['theme-repo'] = array (
"path" => "/var/www/example.com/htdocs/wp-content/plugins/theme-repo" ,
"branch" => "stable"
);
// DO NOT EDIT BELOW THIS LINE
$payload = json_decode(file_get_contents("php://input"));
if (!isset($payload)) exit();
// if repo-name and branch matches
if ( isset ( $repos[$payload->repository->name] ) && ("refs/heads/" . $repos[$payload->repository->name]["branch"]) === $payload->ref ) {
shell_exec( 'cd ' . $repos[$payload->repository->name]["path"] . '/ && git reset --hard HEAD && git pull' );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment