Created
February 18, 2017 09:00
-
-
Save cobbdb/452cf2cbebf49db9744806e503262683 to your computer and use it in GitHub Desktop.
Github webhook quick example
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 | |
function writeLog($msg) { | |
$fout = fopen('log.txt', 'w'); | |
fwrite($fout, $msg); | |
fclose($fout); | |
} | |
$headers = getallheaders(); | |
if (array_key_exists('X-Github-Event', $headers)) { | |
if ($headers['X-Github-Event'] === 'push') { | |
$body = file_get_contents('php://input'); | |
$data = json_decode($body); | |
if ($data->ref === 'refs/heads/master') { | |
writeLog("Something happened to master!\n\n"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment