LoginSignup
0
0

More than 5 years have passed since last update.

capistrano3でリポジトリのURLを変更した時にやること

Last updated at Posted at 2017-10-04

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
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0