use subversion to publish websites

Sometimes I'm really surprised about myself... especially how lazy I am. :-)


I'm currently playing around with one of my private websites, and to improve developing I decided to use subversion. So far so good, but I wanted that the committed subversion code was automatically online on the webserver. So I did the following very simple trick.


First I check out the code (subtree) from the subversion server (which is using https):


$ cd /sites
$ mv dev.adslweb.net{,-backup}
$ svn co https://svn.adslweb.net/svn/websites/dev.adslweb.net


Next step was to commit the current content of the website into subversion:


$ cd /sites/dev.adslweb.net
$ cp -Rv /sites/dev.adslweb.net-backup/*  ./
$ svn add *
$ svn commit -m "Initial commit of ADSLWEB.net dev env"


Now download the simple script I created for making sure that subversion doesn't fire off twice for updating the same tree.


Download svn-update.sh via this link.


So something like this:


$ mkdir ~/scripts/
$ cd ~/scripts
$ wget http://www.xs4all.nl/~paderijk/pics/svn-update.sh
$ chmod 700 svn-update.sh


Now... the last step... create a crontab entry with the following content:


*/1 * * * * /home/pieter/scripts/svn-update.sh /sites/dev.adslweb.net 2>&1 > /dev/null


 And guess... and it works like a charm, on every new commit done by whoever... you get your online site updated within 1 minute without the need log in into the website/webserver using ftp/ssh/whatever.