我使用Capistrano 3部署WordPress项目(在Bedrock WP堆栈中实现:https : //github.com/roots/bedrock)。
WordPress特别支持许多功能,这些功能可以更新生产/登台站点的实际代码(插件更新,某些插件的设置文件等),在各种情况下,我可能想直接将这些代码更改提交给项目GIT存储库一台服务器。
因此,问题是,是否有一种方法可以配置Capistrano Deploy以将.git存储库保留在relase目录中?
我认为使用Cap 2的“复制策略”设置可以做到这一点,但是我找不到关于Cap 3的任何信息。
我已经通过修改由https://github.com/Mixd/wp-deploy项目实现的自定义部署策略解决了这一问题。
注意更改的context.execute
行。
# Usage:
# 1. Drop this file into lib/capistrano/submodule_strategy.rb
# 2. Add the following to your Capfile:
# require 'capistrano/git'
# require './lib/capistrano/submodule_strategy'
# 3. Add the following to your config/deploy.rb
# set :git_strategy, SubmoduleStrategy
module SubmoduleStrategy
# do all the things a normal capistrano git session would do
include Capistrano::Git::DefaultStrategy
# check for a .git directory
def test
test! " [ -d #{repo_path}/.git ] "
end
# same as in Capistrano::Git::DefaultStrategy
def check
test! :git, :'ls-remote', repo_url
end
def clone
git :clone, '-b', fetch(:branch), '--recursive', repo_url, repo_path
end
# same as in Capistrano::Git::DefaultStrategy
def update
git :remote, :update
end
# put the working tree in a release-branch,
# make sure the submodules are up-to-date
# and copy everything to the release path
def release
release_branch = fetch(:release_branch, File.basename(release_path))
git :checkout, '-B', release_branch,
fetch(:remote_branch, "origin/#{fetch(:branch)}")
git :submodule, :update, '--init'
# context.execute "rsync -ar --exclude=.git\* #{repo_path}/ #{release_path}"
context.execute "rsync -ar #{repo_path}/ #{release_path}"
end
end
现在,此解决方案将发行版作为GIT存储库部署到基于发行版ID的自定义分支。
然后可以将其提交并推送到主仓库中,以根据需要进行合并。
所有功劳归功于WP-Deploy项目的创建者Aaron Thomas。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句