Reputation: 968
I'm trying to install a webhook in Github that will instruct my remote server to automatically pull from my Github repository whenever I push to the same repository, but it is not working as expected.
I followed the instructions in this guide (in the Automatic Git Pull on Server section). Here is exactly what I did:
--I created a simple PHP file containing only the line:
<?php `git pull`;’ >
and loaded it onto my web server.
--I then created the webhook in Github to run this file every time a push event occurs (I have double and triple checked that the correct file and path are specified).
But this is not working as expected. To be clear, the webhook fires as expected (whenever I push to Github), but the pull does not occur as expected. Any thoughts why? Perhaps syntax error? Perhaps permission error? Troubleshooting suggestions are also welcome. Are there logs I can review that would shed more light?
Possibly Relevant Info
I'm the only person pushing to and pulling from this repository. And currently, every time I push to GitHub, I always follow it up with a manual pull. I was hoping to automate the pull process a bit.
The project in-question is a small (WordPress) website that I am building locally, then pushing to the web server.
Upvotes: 1
Views: 1098
Reputation: 17
The PHP script you wrote doesn't work like this. Try the steps below:
https://domainname.com/deploy.php
to webhooksdeploy.php script code ::
<?php
echo exec('git pull http://github.com/rajatmalik3143/bug-fixes.git')
#echo shell_exec('whoami')
?>
chmod +x deploy.php
chown apache:apache deploy.php
chown apache:apache html/
Upvotes: 1
Reputation: 1
https://github.com/markomarkovic/simple-php-git-deploy/blob/master/deploy.php
I used an old version of this repo, that should work for you
Upvotes: 0