Mirroring a Github Repo with CircleCI

Yoan Pratama Putra
KodeFox
Published in
2 min readFeb 1, 2020
The water mirroring the houses

Playing with CircleCI has been a fun experience for me these past few months. I’ve learned CircleCI by reading bunch of docs and posts from CircleCI and Stack Overflow. I can’t say it’s easy but I’ve certainly enjoyed it. CircleCI provides significant improvements for app developers. It’s fast, powerful and efficient. There are features that have helped a lot like Orbs. Lately, I’ve been recommending CircleCI to everyone ☕️.

In this article, I’ll share my experience and show how to mirror one git repo to another using CircleCI.

First, you will need to generate an SSH key to allow CircleCI to authenticate with your git repository (Github in this case). You can follow this guide to generate an SSH key.

After that, go to your project’s settings in CircleCI.

Open project’s setting in CircleCI

On the left side, click the SSH Permissions inside Permissions section. Find a button called Add SSH Key on the right side and click it to add your SSH private key that you generated above.

Press Add SSH key

A modal will appear with two inputs inside it, Hostname and Private Key. For the hostname, let’s fill use “github.com”. And for the private key, we need to copy it from the step above It’s likely called “id_rsa” (but don’t accidentally paste your regular private key). You can run this line below to copy the contents of the private key to the clipboard:

$ cat ~/.ssh/my_new_key | pbcopy

After that you can submit the modal and a new list will appear with a fingerprint next to the hostname. Let’s copy that fingerprint as we need it inside our CircleCI’s “config.yml”.

The last step is to add the code below into your “config.yml” and put your fingerprint inside it.

config.yml for mirroring

Finally, we’re done! It’s quite easy, right? 🎉

The last thing to do is just push a commit into our repo on master branch and the CircleCI will run your mirroring job to mirror your repo into another repo.

--

--

Yoan Pratama Putra
KodeFox
Editor for

Software Engineer at KodeFox | Google Assistant Enthusiast | Cyclist | Nerd