Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pull Request Builder: PHP Script which triggers Ansible Tower
$payload = $_POST['payload'];
$json = json_decode($payload);
if (isset($json->action)) {
$action = $json->action;
$prNumber = $json->pull_request->number;
switch ($action) {
case 'opened':
exec_script('scripts/build_pr.sh', array($prNumber, true));
break;
case 'synchronize':
exec_script('scripts/build_pr.sh', array($prNumber));
break;
case 'closed':
exec_script('scripts/remove_pr.sh', array($prNumber));
break;
}
} else {
if ($ref = $json->ref) {
if (preg_match('{/(v[0-9a-zA-Z]+\.[0-9a-zA-Z]+\..+)$}', $ref, $matches)) {
$version = $matches[1];
exec_script('scripts/build_release.sh', array($version));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.