使用Capistrano 3部署git子模块

问题描述 投票:2回答:2

我的项目回购包括Wordpress作为git子模块。通过Capistrano 3进行部署时,子模块目录是贫瘠的。

project
--wordpress
--images

我正在使用git和:deploy_via, :remote_cache

如何告诉Capistrano还部署子模块?

git deployment capistrano git-submodules capistrano3
2个回答
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

3
投票

可能与capistrano v3 deploy git repository and its submodules重复。

在capistrano 3.1.x及更高版本中,您可以实现自己的SCM策略。有一个可用的宝石,有助于git子模块,请参阅:https://github.com/i-ekho/capistrano-git-submodule-strategy

注意:如果您已尝试使用默认的git策略,则repo文件夹可能有问题。只需转到deploy目录并将其删除,然后再次运行cap deploy来修复它。

© www.soinside.com 2019 - 2024. All rights reserved.