Skip to content

Instantly share code, notes, and snippets.

@frippz
Last active July 29, 2016 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frippz/5678296 to your computer and use it in GitHub Desktop.
Save frippz/5678296 to your computer and use it in GitHub Desktop.
Github webhook PHP script
<?php
try {
// Decode JSON data from Github
$payload = json_decode($_REQUEST['payload']);
}
catch(Exception $e) {
exit(0);
}
// Deploy live if push was on master branch
if ($payload->ref === 'refs/heads/master') {
exec('./deploy-master.sh');
}
// Deploy staging if push was on stage branch
if ($payload->ref === 'refs/heads/stage') {
exec('./deploy-stage.sh');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment