Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created October 11, 2010 02:04
Show Gist options
  • Save cowboy/619858 to your computer and use it in GitHub Desktop.
Save cowboy/619858 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' );
}
?>hi
@timothyferriss
Copy link

Always be cautious when running shell commands from web scripts backpack battles for security reasons. Sanitize inputs, restrict access, and log activities to avoid potential vulnerabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment