Skip to content

Instantly share code, notes, and snippets.

@rodrigocnascimento
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodrigocnascimento/567176913cbe9d925907 to your computer and use it in GitHub Desktop.
Save rodrigocnascimento/567176913cbe9d925907 to your computer and use it in GitHub Desktop.
<?php
$json = file_get_contents('php://input');
$data = json_decode($json, true);
$branch = $data['ref'];
$repo = isset($_GET['repo']) ? $_GET['repo'] : '';
$fs = fopen('commit_logs/' . $repo . '-commit.' . date('ymdhis') . '.log', 'a');
fwrite($fs, $branch . '/' . $repo . PHP_EOL);
fwrite($fs, print_r($data, true) . PHP_EOL);
if ($branch === 'refs/heads/master') {
$exec = sprintf("sh /home/Project/deploy/master_deploy.sh %s 2>&1", $repo);
exec($exec);
}
$fs and fclose($fs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment