How can I clone a private repository as part of my deploy commands within the Okteto manifest?

Hi!

I have an Okteto manifest where I need to clone a private repository as part of the deploy commands, something like this:

deploy:
  commands:
  - name: "Clone private repository"
    command: git clone git@github.com:my-user/my-private-repo.git
....

When I execute this manifest locally, it works because it is using my local ssh key, but when I deploy the repository from the UI I’m getting the following error:

git@github.com: Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists

I tried configuring the GitHub App giving access to the repository, but that only works If I deploy directly that repository from the UI, but it doesn’t work If I want to clone it as part of other’s repository manifest.

How can I make it work?

When deploying a git repository from the Okteto UI, a job is created in the cluster. The git repository is cloned into this pod, and then the deploy commands are executed. When cloning the main git repository, Okteto utilizes both the GitHub App (if configured) and the cluster SSH Key.

The SSH Key is mounted in the pod, allowing you to use it to clone other git repositories as part of your deploy commands. Conversely, the GitHub App cannot be employed for this purpose. In summary, if you need to clone a private git repository as part of your deploy commands, it is essential to configure the SSH Key of the cluster in your private git repository and grant access to it.