When working with GitHub workflows it’s possible to checkout different repositories to the one that the workflows are present in. However if the source repository is private you’ll get a not found error when trying to clone it even if the target repository is in the same organisation as the source.

It’s possible to use a personal access token as authentication to allow access but a safer option is to use a deployment key. For this you need to generate the SSH keys locally, add the public key as a deployment key to the private repo and add the private key as a secret to the repo you want to clone the private repo to.

SSH keys can be generated with the below command as described here.

ssh-keygen -t ed25519 -C "your_email@example.com"

Once the keys have been added you can clone the repository in your workflow like so.

- uses: actions/checkout@v3
  with:
    ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
    repository: organization_name/repo_name

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *