This is a simple PHP script. Automatically pull from a repository to a web server (using a webhook on GitHub, GitLab, or Bitbucket) and support git branch
Here we install and setup git on the server, we also create an SSH key so the server can talk to the origin without using passwords etc
Check is git installed before ?
git --version
ssh-keygen -t rsa
Go to ssh directory and find id_rsa.pub file copy content in clipboard.
Paste the deploy key you generated on the server before
Enter the URL to your deployment script - http://server.com/deploy.php
Here we clone the origin repo into a chmodded /var/www/html folder you might clone it somewhere else
sudo chown -R www-data:www-data /var/www/html
sudo -Hu www-data git clone git@github.com:you/server.git /var/www/html
- https://gist.github.com/oodavid/1809044 who in turn referenced