I’ve been using Deployer for a long time mainly because it makes the deployment of PHP applications a breeze.

However, recently I’ve stumbled upon on the problem with git submodules – it turns out that Deployer does not support deploying applications which have submodules.

After digging into the source code, here’s the solution I think is appropriate in this case.

Create a custom task

task('git:submodule_update', function () {  
    cd('{{release_path}}');  
    run('git submodule init');  
    run('git submodule update');  
});

Make it run

Usually I have a separate deploy task which means I can hit dep deploy and have the app deployed. My current setup, including the task above, is:

task('deploy', [  
    'deploy:prepare',  
    'git:submodule_update', // add it before publishing the release but after making preparations  
    'deploy:publish',  
]);

Change update_code_strategy

The update_code_strategy defines how Deployer pulls the code. Set it to clone so that in the release path you could run git commands.

Now whenever you hit dep deploy, the submodules will also be fetched and places inside your releases.