Skip to content

Instantly share code, notes, and snippets.

@jk2K
Forked from cowboy/github_post_recieve.php
Created September 21, 2015 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jk2K/b5b47f659ef76a1d6ec1 to your computer and use it in GitHub Desktop.
Save jk2K/b5b47f659ef76a1d6ec1 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.
if ( $_POST['payload'] ) {
shell_exec( 'cd /srv/www/git-repo/ && git reset --hard HEAD && git pull 2>& 1' );
echo 'success';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment