1. deploy.rbを変更
config/deploy.rbのrepo_url
を変更し、update_git_repo
タスクを追加する
config/deploy.rb
set :repo_url, "git@bitbucket.org:hoge/fuga.git"
task :update_git_repo do
on release_roles :all do
with fetch(:git_environmental_variables) do
within repo_path do
current_repo_url = execute :git, :config, :'--get', :'remote.origin.url'
unless repo_url == current_repo_url
execute :git, :remote, :'set-url', 'origin', repo_url
execute :git, :remote, :update
execute :git, :config, :'--get', :'remote.origin.url'
end
end
end
end
end
参考: https://github.com/capistrano/capistrano/issues/612#issuecomment-70464554
2. リポジトリを更新する
bundle exec cap <STAGES=staging,production> update_git_repo
3. デプロイを実行する
bundle exec cap <STAGES=staging,production> deploy