Created
June 11, 2013 06:06
-
-
Save faishal/5754756 to your computer and use it in GitHub Desktop.
Web hook php sample code for activeCollab
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 | |
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
$repos= array(); | |
$repos['repo-name'] = array( | |
"path" => "/var/www/....", | |
"branch" => "stable" | |
); | |
//error_log(file_get_contents("php://input")); | |
// DO NOT EDIT BELOW THIS LINE | |
$payload = json_decode(file_get_contents("php://input")); | |
if (!isset($payload)){ | |
error_log("No 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('chmod 400 /var/www/.ssh/id_rsa && cd ' . $repos[$payload->repository->name]["path"] . '/ && git reset --hard HEAD && git pull origin ' . $repos[$payload->repository->name]["branch"]); | |
}else{ | |
//error_log("No Commits"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment