Gitlab Pipeline to Clone from Private Github repo
I want to clone some private repositories from Github when I run my pipelines on Gitlab on my project. The main project is hosted on Gitlab.
This is my gitlab.yml
part where I try to add the key:
- eval $(ssh-agent -s)
- echo "$GITHUB_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan github.org >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
I have stored the $GITHUB_PRIVATE_KEY
as a variable. It is a private SSH key and inserted to Gitlab as a key string - single line.
The snippet above is executed during "script".