stalwil
stalwil

Reputation: 125

Git auto pull from repository into staging server?

I've been searching all over the place for an answer to this question. I know there are questions like this already but I can't seem to find a straight answer.

How do I auto pull from a github repository into my staging server?

I have my local files that I am pushing into my repository but then I want those files to automatically be pulled into my staging server.

My ssh deploy key is setup correctly in my github account. Whenever I ssh into my staging server and do a manual git pull command...it works just fine. But now I want that to be automatic.

I created a webhook in my github account with a payload URL that points to a PHP file with this code but i dont think its working:

<?php `git pull [email protected]:user/repo.git`; ?>

I'm not sure if I setup the webhook correctly.

Can someone please help me?

Upvotes: 0

Views: 1058

Answers (2)

Jeroen
Jeroen

Reputation: 312

If the deployment script is in a different directory, be sure to CD into the correct directory in the staging server.

<?php `cd /your/repo/location && git pull`; ?>

Upvotes: 1

Mukesh Ram
Mukesh Ram

Reputation: 6338

follow these steps

1) in your staging server create a file called githubupdate.php and add below content in that file

<?php `git pull`;?>

2) now go to github account and open your repo's settings 3) Click on webhooks and addwebhook, in webhook you have to add above url e.g http://www.yoursite.com/githubupdate.php 4) now try to push from local and check it work ?

Upvotes: 0

Related Questions