Skip to content

Instantly share code, notes, and snippets.

@drklrd
Forked from yosukehasumi/git-auto-deploy.md
Created March 22, 2018 15:42
Show Gist options
  • Select an option

  • Save drklrd/5f029be60a5cc06a6b0e33c1e79973d1 to your computer and use it in GitHub Desktop.

Select an option

Save drklrd/5f029be60a5cc06a6b0e33c1e79973d1 to your computer and use it in GitHub Desktop.
Setting Up Git-Auto-Deploy on Digital Ocean

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

{
  "pidfilepath": "/etc/git-auto-deploy/.gitautodeploy.pid",
  "host": "0.0.0.0",
  "port": 8001,
  "repositories": [
    {
      "url": "[email protected]:user/repo.git",
      "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

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 [email protected]:user/repo.git
git fetch origin

Next make sure you add your public key from /root/.ssh/id_rsa.pub to gitlab and add a webhook that triggers the "push" event to http://mydomain.com:8001

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

service git-auto-deploy start
service git-auto-deploy status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment