Multiple deploy keys for GitHub

I had some time to test a few things. I wasn’t able to get things up and running via host aliases yet, but I found another embarassingly simple solution that is less versatile but works fine at least if you have only one more repo that you need to access:

  1. Generate the SSH deploy key for GitHub and add it there. (Make sure it’s without password)

  2. Add it to CircleCI settings via the web interface under the section “SSH Keys” and set the host to “github.com” (or wherever your repo lies)
    When defining your job in the config.yml do this, in the exact order:

     steps:
       - checkout # First check out your repo with the given SSH checkout key
       - add_ssh_keys: # THEN set the *new* SSH key for github.
           fingerprints:
               - "<your fingerprint>"
    

So basically after the first checkout you tell CircleCI to use a different SSH key for GitHub for the next requests. This works well for accessing one more repo. However things will get really messy when you try to use the same method for accessing a third, fourth… repo. For that you will still need to use aliases. When I have the time I will try to find a solution for that aswell. But in the meanwhile, this works nice.

This might be especially interesting for other iOS projects like us that are using fastlane match. :slight_smile: