Last active
May 11, 2018 22:22
-
-
Save davidsword/ab2089e5592223aee454cb10a78b5a38 to your computer and use it in GitHub Desktop.
Github deploy webhook location to pull any pushes from master
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 | |
// just a pinch of authorization | |
$sig = hash_hmac('sha1', file_get_contents('php://input'), 'mywebhooksecrethere'); | |
if ( | |
$_POST['payload'] && | |
$_SERVER['HTTP_X_GITHUB_EVENT'] == 'push' && | |
$_SERVER['HTTP_X_HUB_SIGNATURE'] == 'sha1='.$sig | |
) { | |
$cmd = 'cd /var/www/path/to/repo && /usr/bin/git reset --hard HEAD 2>&1 && /usr/bin/git pull 2>&1'; | |
$out = shell_exec( $cmd ); | |
echo preg_match("/[up-to-date|Updating]/",$out) ? "🚀" : "🚫 {$out}"; | |
} else { | |
echo "🤷🏼"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment