Created
October 15, 2015 06:38
-
-
Save RadGH/28b8cca5f8ec0b11f5e5 to your computer and use it in GitHub Desktop.
Git auto pull on commit from Bitbucket with PHP + Webhook
This file contains hidden or 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 | |
| // Set up a webhook for your Bitbucket repo (or other service) that will visit this script (eg, http://example.org/git-pull.php). | |
| // When you commit, Bitbucket will visit that URL. | |
| // Now the script below runs, which will then pull from the bitbucket repo, grabbing the recently uploaded commit. | |
| // All you have to do is push to Bitbucket! | |
| // NOTE: This script relies on shell_exec and may not work on shared hosts. | |
| $LOCAL_REPO = "/ABSOLUTE/PATH/TO/LOCAL/GIT/REPO/"; | |
| $REMOTE_REPO = "https://YOUR_USERNAME:YOUR_PASSWORD@URL_TO_YOUR_REMOTE_GIT_REPO"; | |
| shell_exec("cd {$LOCAL_REPO} && git pull {$REMOTE_REPO}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code needs to be writable by the user that runs the
webserver. Is that safe?