Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial automated deployment

I'm in the process of looking for a way to streamline the deployment of one of our php web applications (if it works on this I'll roll it out to other apps).

I quite like the look of this: http://www.springloops.com/, but it's SVN and we're using mercurial.

Unfortunately we have no shell access to our current server, so something that works over ftp would be best, if anyone has any ideas?

like image 913
richzilla Avatar asked Apr 21 '10 14:04

richzilla


2 Answers

You'll want to use mercurial's hg archive command from a hook. It takes a snapshot of the revision you indicate (via tag, etc.) and then exports it.

In your "production" repository's hgrc you could have something like this:

[hooks]
changegroup = ./doDeploy.sh

and then ./doDeploy.sh would have in it:

hg archive -r tip /tmp/deployme
ftp /tmp/deployme ftp://remoteserver

You'll end up having to work around all sorts of little glitches like file permissions, files that have been deleted from the repo but still exist on the server, etc. but in general that provides a good framework for a system that, upon having changes pushed to it by a release manager automatically uploads a snapshot to alive system.

like image 198
Ry4an Brase Avatar answered Sep 26 '22 02:09

Ry4an Brase


That's my 5 cents: The ftp part of the answer only works for projects without subdirectories (FTP doesn't suports them) if you want to keep really all in sync here is my sh script (it uses LFTP, the -e option deletes files remotely that are no longer present locally):

#!/bin/sh
rm -rf /home/user/tmp/deploy/*
hg archive -r tip /home/user/tmp/deploy/
lftp -u username,password your.ftpsite.com << END_SCRIPT
set ftp:ssl-allow no
cd httpdocs/yoursite/
mirror -R -e --only-newer --log=/home/user/lftp.log /home/user/tmp/deploy .
END_SCRIPT
echo "#--- $(date)"  >> /home/user/lftp.log
exit 0
like image 45
Vlax Avatar answered Sep 22 '22 02:09

Vlax