Skip to content

Instantly share code, notes, and snippets.

@TechNickAI
Created December 26, 2012 18:41
Show Gist options
  • Save TechNickAI/4382130 to your computer and use it in GitHub Desktop.
Save TechNickAI/4382130 to your computer and use it in GitHub Desktop.
php script for github webhook
<?php
function output($log) {
echo $log . "\n";
file_put_contents('lastrun', $log);
}
$log = date('r') . "\n";
if (empty($_POST['payload'])) {
output($log . "No payload");
exit(1);
}
$decoded = json_decode($_POST['payload'], true);
$log .= print_r($decoded, true);
if ($decoded['ref'] != "refs/heads/master") {
output($log . "Not master - " . $decoded['ref']);
exit(1);
}
$log = $log . $decoded['repository']['name'] . "\n";
switch ($decoded['repository']['name']) {
case 'pilotfish.io':
`touch deploy_pilotfish.io`;
break;
case 'pilotfish.github.com':
`touch deploy_pilotfish.github.com`;
break;
case 'aboinga.com':
`touch deploy_aboinga`;
break;
case 'creationeer.me':
`touch deploy_creationeer`;
break;
case 'package.json-validator':
`touch deploy_package.json-validator`;
break;
case 'positiveretribution':
`touch deploy_positiveretribution`;
break;
default:
$log = $log . 'Unrecognized repo:' . $decoded['repository']['name'] . "\n";
}
output($log);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment