Skip to content

Instantly share code, notes, and snippets.

@rahul286
Last active September 28, 2019 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul286/5597783 to your computer and use it in GitHub Desktop.
Save rahul286/5597783 to your computer and use it in GitHub Desktop.
<?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