Skip to content

Instantly share code, notes, and snippets.

@svandragt
Forked from frippz/github-webhook-deploy.php
Created July 29, 2016 10:10
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 svandragt/93dfa28397b4690afe949d96165535e3 to your computer and use it in GitHub Desktop.
Save svandragt/93dfa28397b4690afe949d96165535e3 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