Deploying a git submodule with Capistrano 3

Deadly 提交于 2019-12-07 22:36:19

问题


My project repo includes Wordpress as a git submodule. When deploying via Capistrano 3, the submodule directory is barren.

project
--wordpress
--images

I am using git and :deploy_via, :remote_cache

How can I tell Capistrano to also deploy the submodule?


回答1:


I found a great script from corny that overrides the git task in Capistrano.

Place this script in lib/capistrano/tasks/git.cap and use cap stage deploy as normal.

https://gist.github.com/corny/7459729

# Save this file as lib/capistrano/tasks/git.cap

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



回答2:


Probably duplicated with capistrano v3 deploy git repository and its submodules.

In capistrano 3.1.x and later you can implement your own SCM strategy. There is an available gem that helps with git submodule, please see: https://github.com/i-ekho/capistrano-git-submodule-strategy.

NOTE: you may have problem with the repo folder if you already tried with the default git strategy. Simply go to the deploy directory and remove it and then run cap deploy again to fix it.



来源:https://stackoverflow.com/questions/22819265/deploying-a-git-submodule-with-capistrano-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!