Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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