SSH configuration

Copy your SSH key to the devops server

(webapp@web)_$: ssh-copy-id -i .ssh/id_rsa.pub txgit@devops.example.com

Create a production repository

(root@web)_$: mkdir -p /var/webapp
(root@web)_$: virtualenv /var/webapp/venv
(root@web)_$: chown webapp:webapp -R /var/webapp
(webapp@web)_$: cd /var/webapp/venv
(webapp@web)_$: git clone ssh://txgit@devops.example.com/srv/git/webapp.git
/var/webapp/.git/config:
------------------------
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = ssh://txgit@devops.example.com/srv/git/webapp.git
[branch "master"]
	remote = origin
	merge = refs/heads/master

Pull from remore repository

(webapp@web)_$: cd /var/webapp
(webapp@web)_$: git fetch --all
(webapp@web)_$: git pull origin master
(webapp@web)_$: git pull origin develop
(webapp@web)_$: git checkout --track origin/develop

Poor man’s continuous deployment

/home/webapp/webapp-update.sh:
------------------------------
REPO_PATH="/var/webapp"
GIT="/usr/bin/git"

cd ${REPO_PATH}
$GIT fetch --all

# Update all branches
branches=( "master" "develop" )
for branch in "${branches[@]}"
do
    $GIT checkout ${branch} && $GIT pull origin ${branch}
done

# Go back to master
$GIT checkout master
(webapp@web)_$: crontab -e
...
# m h  dom mon dow   command
MAILTO=""
*/15 * *   *   *     /home/webapp/repo-update.sh