简体   繁体   中英

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 git@github.com:user/repo.git`; ?>

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

Can someone please help me?

如果部署脚本位于其他目录中,请确保将CD放入暂存服务器中的正确目录中。

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

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 eg http://www.yoursite.com/githubupdate.php 4) now try to push from local and check it work ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM