Last active
September 28, 2019 14:59
-
-
Save rahul286/5597783 to your computer and use it in GitHub Desktop.
Sample webhook for https://rtcamp.com/activecollab-gitolite/
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 | |
$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