Skip to content

Instantly share code, notes, and snippets.

@micjamking
Created February 4, 2017 03:50
Show Gist options
  • Save micjamking/08b3d0a41e505cfb0a85cbc961ac5ae9 to your computer and use it in GitHub Desktop.
Save micjamking/08b3d0a41e505cfb0a85cbc961ac5ae9 to your computer and use it in GitHub Desktop.
GitHub PHP webhook to auto-pull on repo push (w/ secret key)
<?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