Last active
July 29, 2016 10:10
-
-
Save frippz/5678296 to your computer and use it in GitHub Desktop.
Github webhook PHP script
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 | |
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