Google Cloud Source Repositories is Google’s hosted git service. We use Google Cloud Functions a lot, and prefer to deploy our functions from a code repository so that we can keep a track of revision history and manage rollbacks. We utilise Git and GitHub for our version control. However, we need to use Cloud Source Repositories for deploying Cloud Functions; but we didn’t want to be managing multiple version control systems.
Luckily, we are able to mirror GitHub (and Bitbucket) repositories in Google Source Repositories so that Google can take care of syncing your code bases. This way we can utilise GitHub as our central point for code, and Google takes care of syncing those changes with its own system. Easy!
Below, we outline the steps on how to set up syncing with your GitHub repositories. This supports both public and private repositories.
Once set up, and when editing code, please make sure you are committing and pushing changes to the GitHub repository as the mirroring on Google Source Repositories is read-only.
- Log into the Google Cloud Platform Console
- Using the hamburger menu navigate to Tools > Source Repositories
- Click on + Add repository
- Select Connect external repository then click on Continue
- Use the following settings:
- Project: The project that will house the source repository
- Git provider: GitHub
- Tick consent box
- Click on Connect to GitHub
- You should now be in the GitHub OAuth dialog for your personal account
- If you are linking repositories for an organisation that you belong to, click on the Grant button next to it
- Click on Authorize GoogleCloudPlatform
- You will be taken back to the Google Cloud Console
- Select the repository you wish to link
- Click on Connect selected repository
- The repository will be imported into Cloud Source Repositories. The name of the repository will look like