Created
July 29, 2014 11:32
-
-
Save tobalsan/4767985370b6cb0ded3c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
header("Content-type: text/plain"); | |
$json = file_get_contents('php://input'); | |
$data = json_decode($json,true); | |
$file = __DIR__ . '/../app/logs/git.log'; | |
$date = date('Y-m-d H:i:s'); | |
if(!count($data['commits'])) { | |
file_put_contents($file,"\n" . $date . " : Failed attempt to trigger git web hook (by ip " . $_SERVER['REMOTE_ADDR'] . ")", FILE_APPEND); | |
exit('Direct access to this resource is not allowed.'); | |
} else { | |
`cd .. | git pull`; | |
file_put_contents($file,"\n" . $date . " : Successful update by git web hook (by ip " . $_SERVER['REMOTE_ADDR'] . ")", FILE_APPEND); | |
exit('Hook successfully triggered'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment