Question

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?

Was it helpful?

Solution

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;");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top