simple-php-git-deploy icon indicating copy to clipboard operation
simple-php-git-deploy copied to clipboard

How to deal with submodules that are also private

Open Ma-ve opened this issue 9 years ago • 0 comments

I've got another repo that contains my images (about 60MB of them). That repo is being submodule'd under img. A problem is that I can't use the same deploy key, because GitHub says no-no. One way to solve this is by generating another ssh key, and inputting that deploy key on the images repo.

What would be a good way of implementing this in deploy.php be? Obviously you could define a submodules array, with the submodule dir and whether or not it's private, and loop through that. That isn't nice, because you lose looseness if I introduce another submodule locally.

Another way would to ask for input from the command line, asking for the location to a second ssh key that's deployed on the second repo: StackOverflow answer for command line input here. But then you'll ask for input from the command line which is ridiculous, considering it should be an automatic deploy.

One way I've solved it right now is by replacing:

$commands[] = sprintf(
    'git submodule update --init --recursive'
);

with

$commands[] = sprintf(
    "ssh-agent bash -c 'ssh-add /var/www/.ssh/id_rsa_img; git submodule update --init --recursive'"
);

This obviously only works because I have only one submodule. /var/www/.ssh is the default dir that Apache's www-data looks for ssh keys. Anyone have any suggestions?

Maybe find a way to specify only the ssh key's name? With a strtolower from the last part of the submodule name?

Ma-ve avatar Jun 09 '16 07:06 Ma-ve