Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git deploy with submodules

I've been looking into different ways of deploying sites using git, and found the following tutorial:

http://42pixels.com/blog/quick-and-dirty-git-deployment

I like the ideas presented in this tutorial, and would be keen on using it for my sites, only it doesn't seem to support submodules.

Is there anyway that this can be changed so that submodules are also pulled in and updated as required?

Thank you.

UPDATE

I've been working on this problem for the last couple of hours, and I seem to be making progress, but I still can't get it working.

I've switched to this tutorial: http://toroid.org/ams/git-website-howto (which is mostly the same, just a few slight changes), and after following some advice found here: https://stackoverflow.com/a/6636509/1049688 I've ended up with a post-receive file that looks like this:

#!/bin/sh

export GIT_WORK_TREE=/srv/www/limeblast.co.uk/htdocs_test
export GIT_DIR=/srv/www/limeblast.co.uk/.git
cd $GIT_WORK_TREE

git checkout -f master
git submodule init
git submodule update

This all seems fine in theory, and it would appear that the submodule commands are running, but I'm getting the following error messages back:

remote: Submodule 'wordpress' (git://github.com/WordPress/WordPress.git) registered for path 'wordpress' remote: Submodule 'wp-content/themes/limeblastevolution/inc/cssCrush' (git://github.com/peteboere/css-crush.git) registered for path 'wp-content/themes/limeblastevolution/inc/cssCrush' remote: fatal: working tree '/srv/www/limeblast.co.uk/htdocs_test' already exists. remote: Clone of 'git://github.com/WordPress/WordPress.git' into submodule path 'wordpress' failed

Any ideas? Thank you.

like image 572
Daniel Hollands Avatar asked May 11 '12 16:05

Daniel Hollands


1 Answers

You might have success with git-deploy.

But if that is too much focused on Rails or if you cannot or will not use it for other reasons, here is how to force a submodule update in a post-commit hook:

git submodule init && git submodule sync && git submodule update

You must run this on the server; so probably best to add it to your hooks/post-receive script. It is simple BASH or SH, bytheway.

like image 60
berkes Avatar answered Oct 12 '22 23:10

berkes