문제

I want to create a script for git which is triggered when there is an update to a repo and does "git pull" on our remote server.

I have a very basic version in which a POST message is set to the URL on our server which would have the content

<?php `git pull`; 

In it, no problem there. However the dev domain is actually a fake domain which nginx redirects to on my server (url.dev) so I can't point to it this way. My idea was to point another live domain to a subfolder on the dev server, so the top level directory can't be accessed, but then of course running "git pull" from that directory won't work. Is there anyway in PHP to run the command so that it "CD"'s into the correct director and Gitpulls or is this not possible with php?

도움이 되었습니까?

해결책

If you add the public keys to the user that is running your scripts (usually www-data) you can do this

    system("/path/to/executable/git pull;echo \"\nLast commit\";  /path/to/executable/git log -2;");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top