Out of the box Autopkg(r) doesn’t support adding private GitHub repositories, however it is possible to get a private repo working well with Autopkg(r) with just a little extra setup. Here’s how I did it.
Set up a Deploy Key
The first thing you will need to do is set up a deploy key for your repo. Create your key on the machine which you will be using Autopkg by running the following command in terminal:
ssh-keygen -t rsa -b 4096 -C autopkg-deploy-key
Note: you can list anything you want after -C, as it’s just a comment.
Follow the prompts in terminal to finish creating your ssh key. I named mine autopkg-deploy-key, but you can name yours whatever you want.
Once your key pair is created, find the public key (the filename will end in .pub) and copy it’s contents to your clipboard. You will need it in the next step.
Navigate to your repository’s GitHub page, and click on Settings, then Deploy keys, and finally Add deploy key.
Paste the contents of your public key into the “Key” box as shown, then click “Add key.”
You should now see your new key on the Deploy keys page.
Clone Your Private Repo
Now that we have a deploy key set up, it’s time to clone the private repo to the local machine so that Autopkg can access it. Use the following command in Terminal to clone your repo.
git clone firstname.lastname@example.org:<your-github-org>/<your-private-repo>.git ~/Library/AutoPkg/RecipeRepos/<your-repo-identifier>
Verify that your repo has been cloned into ~/Library/AutoPkg/RecipeRepos.
Edit the Autopkg preference file
Now we have to edit the Autopkg preference file so that it knows about our new private repository.
First, convert the preference file to XML:
plutil -convert xml1 ~/Library/Preferences/com.github.autopkg.plist
Now we need to add the private repo to both the RECIPE_REPOS and RECIPE_SEARCH_DIRS keys in the com.github.autopkg.plist. They should look something like this:
Once you have made your changes, be sure to save the file.
Now that your repo is set up, it’s time to test! You can verify that Autopkg is configured correctly by running:
Autopkg should return the private repo you have added.