Felix Ogg
Felix Ogg

Reputation: 852

Automate mirroring GitHub to GCP Source Repository?

We run Google Cloud Functions (python), which require to be deployed from Google Cloud Source Repository. Since all the code is stored on GitHub we resort to first mirroring GitHub into Source Repository. Although this only requires a few mouse clicks, it becomes a burden to repeat over 3+ projects (dev, staging, production) times 5+ repos (5+ apps).

I am looking to automate the mirroring config, preferably to add into the Terraform automation we already use, into a hands-off project configuration. Does the Google API support this mirroring automation? So far on my Google Cloud expedition everything was available in their API!

I fail to find Terraform examples though, and would appreciate a tip.

Come to think of it, if I can take Source Repository out of the equation, that would be just fine with me too. After all, I only use it as a pass-through / empty shell.

Upvotes: 2

Views: 1571

Answers (2)

Guy Scher
Guy Scher

Reputation: 1

Mirror Object is read only, hence cannot be used in create/update methods.

I'm facing the same problem and it seems like the only way would be from the ui or automate it as a pull-push job of some sort.

Upvotes: 0

Daniel Ocando
Daniel Ocando

Reputation: 3794

The Cloud Source Repository API includes a Repo resource that has a Mirror Config object where you could type in your Github's URL, webhook and credentials to automate this procedure. I would initially test it with the create method, but if you have an existing Cloud Source Repository I believe the patch method will also be worth exploring.

Additionally, there is an open Feature Request in order to connect a repository via the Cloud Build GitHub App that I recommend you to star and follow, as it could further ease your automation needs.

Upvotes: 2

Related Questions