0

Travis CI is not updating the git submodule and it is throwing

ERROR: Permission to appdev/frontend.git denied to deploy key fatal: Could not read from remote repository.Please make sure you have the correct access rights and the repository exists.

I have already created ssh-keygen and added as Deploy key in github, but still its giving permission denied

Submodule 'frontend' (git@github.com:appdev/frontend.git) registered for path 'frontend'
fatal: clone of 'git@github.com:appdev/frontend.git' into submodule path '/home/travis/build/appdev/b2b/frontend' failed
Failed to clone 'frontend'. Retry scheduled

The command "eval git submodule update --init --recursive " failed. Retrying, 2 of 3.

I have added the ssh key in Github Deploy Key

.travis.yaml

language: python

git:
  submodules: true
  quiet: true
  depth: false
...
...
.gitmodules

[submodule "frontend"]
    path = frontend
    url = git@github.com:appdev/frontend.git
  • 1
    Deploy keys are [per reposittory](https://docs.github.com/en/developers/overview/managing-deploy-keys#using-multiple-repositories-on-one-server). You have to have a deploy key for every submodule (please remember submodules are separate repositories) and configure SSH to use these keys. – phd Nov 22 '22 at 10:24
  • @phd I have added deploy key for the submodule too, yet I am getting error – DevOps_Guy_1903 Nov 23 '22 at 04:29
  • How do you configure `~/.ssh/config` so that SSH uses the correct key when cloning the corresponding modules? – phd Nov 23 '22 at 04:49

1 Answers1

0

If a submodule needs to reference a specific deploy key (key1), you need to change the submodule URL, using git submodule set-url -- /path/to/submodule key1:appdev/frontend.git

With key1 an Host entry in your ~/.ssh/config, as commented:

Host key1
  Hostname github.com
  User git
  IdentityFile ~/.ssh/key1

With Travis-CI, that would be done in a before_script step.

Note that Travis-CI recommends using User key instead.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250