Created
April 13, 2015 10:25
-
-
Save tristanbes/616a1758044ac4b54206 to your computer and use it in GitHub Desktop.
Pull Request Builder: PHP Script which triggers Ansible Tower
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
$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