LoginSignup
16
16

More than 5 years have passed since last update.

githubでsubmoduleを含んだdeploy

Last updated at Posted at 2014-07-17

githubのprivate repositoryで、submoduleを含んだプロジェクトをCapistrano 3でdeployするとき。

鍵の問題

githubでは個別のプロジェクトにdeploy keyを登録できるが、同じ鍵を複数のプロジェクトに登録できない。そのため、submoduleに同じ鍵が使えない。
そのため、(a)deploy userを作る(b)プロジェクト毎に鍵をわける、のどちらかが必要。

(a)はdeploy@mydomain.comなどを作成する。

(b)は、以下のように、.ssh/configで別の名前を割り当てれば対処可能。

Host repo-foo
  HostName github.com
  User git
  IdentityFile ~/.ssh/foo_key
  IdentitiesOnly yes

Host repo-bar
  HostName github.com
  User git
  IdentityFile ~/.ssh/bar_key
  IdentitiesOnly yes

cloneするときは以下。

$ git clone repo-foo:username/repository.git

see:
http://stackoverflow.com/questions/10628574/problems-with-git-submodules-when-submodules-are-private-github-repos

Capistrano 3の設定

Capistrano 3ではsubmoduleの設定がないので、追加する必要がある。

see:
http://d.hatena.ne.jp/Dltn/20140528/1401252236
http://stackoverflow.com/questions/23742573/capistrano-submodule-init-and-update-task

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