Surya.dev
Published on

Cloud Source Repositories on Google Cloud

Authors

Cloud Source Repositories are private Git repositories hosted on Google Cloud. These repositories let you develop and deploy an app or service in a space that provides collaboration and version control for your code.

Initial Setup and Deploy to Cloud Functions

Command line reference

Enable API's

terminal
$ gcloud services enable sourcerepo.googleapis.com 
$ gcloud services enable cloudfunctions.googleapis.com

Create Repo

terminal
$ gcloud source repos create csr-demo 

Clone Repo into Cloud Shell

terminal
$ gcloud source repos clone csr-demo 
$ cd csr-demo

Pull copy of GitHub example into directory

terminal
$ git pull https://github.com/linuxacademy/content-gcpro-devops-engineer

Push cloned code into CSR

terminal
$ git push origin master

Test and call the function with custom data

terminal
$ gcloud functions call function-1 --data='{"name":"Matt"}'

I'm going to flip over to our Google cloud project. Let's go ahead and start by exploring the Cloud Source Repository service in creating a new repo via the web console.

For now let's just go ahead and create a new repository and click continue. Image create csr on google cloud
Give it a very simple name of ex: suryarepo-test Image create csr setup repository
Our repo has been created from which we have instructions to how to either connect to it and also push code into our repository and we're going to go Image repo has created

Note: detail documentation how to create a code repository in cloud source repositories