Skip to content

Instantly share code, notes, and snippets.

@jeremyfelt
Created January 6, 2015 04:31
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 jeremyfelt/d48ad2f482a7058bfe9f to your computer and use it in GitHub Desktop.
Save jeremyfelt/d48ad2f482a7058bfe9f to your computer and use it in GitHub Desktop.
<?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