我的项目回购包括Wordpress作为git子模块。通过Capistrano 3进行部署时,子模块目录是贫瘠的。
project
--wordpress
--images
我正在使用git和:deploy_via, :remote_cache
如何告诉Capistrano还部署子模块?
答案 0 :(得分:4)
我发现了一个来自corny的优秀脚本,它覆盖了Capistrano中的git任务。
将此脚本放在lib/capistrano/tasks/git.cap
中并照常使用cap stage deploy
。
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
答案 1 :(得分:3)
可能与capistrano v3 deploy git repository and its submodules重复。
在capistrano 3.1.x及更高版本中,您可以实施自己的SCM策略。有一个可用的gem有助于git子模块,请参阅:https://github.com/i-ekho/capistrano-git-submodule-strategy。
注意:如果您已尝试使用默认的git策略,则可能会遇到repo
文件夹的问题。只需转到deploy目录并将其删除,然后再次运行cap deploy来修复它。