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