Skip to content

Instantly share code, notes, and snippets.

@kujiy
Forked from cowboy/github_post_recieve.php
Last active May 19, 2016 10:11
Show Gist options
  • Save kujiy/3a0c87d97fd91a382e415267c02588e2 to your computer and use it in GitHub Desktop.
Save kujiy/3a0c87d97fd91a382e415267c02588e2 to your computer and use it in GitHub Desktop.
GitHub PHP webhook to auto-pull on repo push
<?php
// Use in the "Post-Receive URLs" section of your GitHub repo.
$path = "/var/www/html/abc";
if ( $_POST['payload'] ) {
shell_exec( 'cd '.$path.' && git reset --hard HEAD && git pull 2>&1' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment