Created
February 4, 2017 03:50
-
-
Save micjamking/08b3d0a41e505cfb0a85cbc961ac5ae9 to your computer and use it in GitHub Desktop.
GitHub PHP webhook to auto-pull on repo push (w/ secret key)
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 | |
$SECRET_KEY = ''; | |
$header = getallheaders(); | |
$hmac = hash_hmac('sha1', file_get_contents('php://input'), $SECRET_KEY); | |
if ( isset($header['X-Hub-Signature']) && $header['X-Hub-Signature'] === 'sha1='.$hmac ) { | |
$payload = json_decode( file_get_contents('php://input')); | |
shell_exec( 'cd /home4/pbshawa1/public_html/wordpress && git reset --hard HEAD && git pull' ); | |
} | |
?> | |
<h1>Aloha!</h1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment