4/3/2018 - 1:26 PM

Git Auto Deplay

Install software-properties-common

sudo apt-get install software-properties-common

Add Repo

sudo add-apt-repository ppa:olipo186/git-auto-deploy

Update apt-get

sudo apt-get update

Install git-auto-deploy

sudo apt-get install git-auto-deploy

Modify /etc/git-auto-deploy.conf.json

  "pid-file": "/etc/git-auto-deploy/",
  "http-host": "",
  "http-port": 8001,
  "repositories": [
      "url": "",
      "branch": "master",
      "remote": "origin",
      "path": "/var/www/html",
      "filters": [
          "object_kind": "push",
          "ref": "refs/heads/master"

Generate key

cd /root/.ssh/; ssh-keygen -t rsa;

copy key to git-auto-deploy

sudo cp /root/.ssh/id_rsa /etc/git-auto-deploy/.ssh/

change permissions for script to git-auto-deploy user

sudo chown -R git-auto-deploy:git-auto-deploy /etc/git-auto-deploy

Add git-auto-deploy user to the www-data group

usermod -a -G www-data git-auto-deploy

For some reason I'm not so good with permission stuff and the above command doesn't work the way i expect, my solution is to change the ownership of the entire html directory

chown -R git-auto-deploy:git-auto-deploy /var/www/html

You may need to make sure that the repo IP fingerprint has been added to the ~/.ssh/known_hosts file and copy this to the git-auto-deploy/.ssh/known_hosts file

ssh-keyscan -H -t rsa  >> ~/.ssh/known_hosts
cp ~/.ssh/known_hosts /etc/git-auto-deploy/.ssh/
chown git-auto-deploy:git-auto-deploy /etc/git-auto-deploy/.ssh/known_hosts

Next make sure you add your public key from /root/.ssh/ to gitlab and add a webhook that triggers the "push" event to

Start and check your git-auto-deploy server by running

service git-auto-deploy start
service git-auto-deploy status

For Digital ocean you may have to open up the 8001 port

sudo ufw allow 8001/tcp

Install git

sudo apt-get install git

You may need to verify the authenticity (fingerprint) of the git repo. In my case this was a Digital Ocean git repo so I ssh'd into my /var/www/html directory and ran

git init
git remote add origin
git fetch origin

To see git-auto-deploy logs you can watch the log file:

tail -f /var/log/git-auto-deploy.log