Created
January 6, 2015 04:31
-
-
Save jeremyfelt/d48ad2f482a7058bfe9f to your computer and use it in GitHub Desktop.
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
<?php | |
// Some stuff to validate the request from GitHub, see documentation | |
// on HTTP_X_GITHUB_EVENT and HTTP_X_GITHUB_DELIVERY | |
$payload = json_decode( $_REQUEST['payload'] ); | |
if ( 'push' === $_SERVER['HTTP_X_GITHUB_EVENT'] && 'refs/heads/develop' === $payload->ref ) { | |
shell_exec( 'sh /var/repos/deploy/deploy-build.sh develop' ); | |
die( 'Deploy develop branch' ); | |
} elseif ( 'create' === $_SERVER['HTTP_X_GITHUB_EVENT'] && 'tag' === $payload->ref_type ) { | |
$tag = $payload->ref; | |
if ( 0 === preg_match( '|^([0-9.])+$|', $tag ) ) { | |
die( 'Invalid tag format' ); | |
} | |
shell_exec( 'sh /var/repos/deploy/deploy-build.sh ' . $tag . ' > /var/www/repo.wsu.edu/deploy/results.txt' ); | |
die( 'Deploy ' . $tag ); | |
} else { | |
echo 'invalid'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment