Capistrano Submodule Init and Update Task

I’m using Capistrano (as part of Bedrock) to deploy WordPress.

I’m also using Composer to manage php dependencies and my WordPress plugins, and I have my theme managed by git as a submodule.

Read More

I’ve got everything setup and I’ve successfully deployed WordPress to my remote server.

The problem is I’m managing my custom theme with git submodules. I can’t find a way to init and update the submodule during the default deployment, or as a separate task. I’d prefer to have it as a separate task as I don’t change the underlining project files too frequently.

  1. I found this gist that creates a task to do the same but its using an older version of Capistrano.

  2. I tried this method but it fails when trying to create the release symlinks.

  3. I tried enabling submodules with set :git_enable_submodules, 1 in my deploy.rb file but that seems to be missing from Capistrano V3.x.

  4. I found this thread where the author of Capistrano explains why submodule support was removed and another commenter posted this gist, which is giving me this error Tasks: TOP => git:create_release => git:update => git:clone.

What are other people doing to enable simple deployments with Capistrano that include git submodules?

Related posts

Leave a Reply

1 comment

  1. i also use git submodule in capistrano 2 i used:

    set :git_enable_submodules, 1

    worked prefctly.

    when i moved into Capistrano 3.x i started to use:

    namespace :git do
      desc 'Copy repo to releases'
      task create_release: :'git:update' do
        on roles(:all) do
          with fetch(:git_environmental_variables) do
            within repo_path do
              execute :git, :clone, '-b', fetch(:branch), '--recursive', '.', release_path
            end
          end
        end
      end
    end
    

    also working like a charm.

    see more details here:

    https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/git.rake#L34
    https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/git.rake#L56