This gist assumes:
- you have a local git repo
- with an online remote repository (github / bitbucket etc)
- servidor cpanel
- exec activo en PHP
- shell access
- remote key
git config --global user.name "Server"
git config --global user.email "server@server.com"
Here we add the SSH key to the origin to allow your server to talk without passwords. In the case of GitHub we also setup a post-receive hook which will automatically call the deploy URL thus triggering a PULL request from the server to the origin
- https://github.com/settings/ssh
- Create a new key
- Paste the deploy key you generated on the server
- https://github.com/oodavid/server.com/admin/hooks
- Select the Post-Receive URL service hook
- Enter the URL to your deployment script - http://server.com/deploy.php
- Click Update Settings
- https://bitbucket.org/account/ssh-keys/
- Create a new key
- Paste the deploy key you generated on the server
- Go to: Repo > Admin > Services
- Select "POST"
- Add the URL to your deployment script - http://server.com/deploy.php
- Save
Here we clone the origin repo into a chmodded /home/USER/public_html folder
sudo chown -R apache:apache /var/www/html
sudo -Hu apache git clone git@github.com:you/server.git /var/www/html