Skip to content

Instantly share code, notes, and snippets.

@faishal
Created June 11, 2013 06:06
Show Gist options
  • Save faishal/5754756 to your computer and use it in GitHub Desktop.
Save faishal/5754756 to your computer and use it in GitHub Desktop.
Web hook php sample code for activeCollab
<?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