This repository contains some basic sample code to illustrate the use of protobufs in setting up gRPC servers in Go, running on Google Cloud Run. It also contains some useful workflows and CI/CD pipelines to help you get started with your own projects.
Buf is a platfrom that is creating an ecosystem of tooling around Protocol Buffers. For our purposes, we use buf to remotely generate the protobuf code for our services.
- Create an account at buf.build
- Navigate to settings by clicking on your profile in the top right corner.
- Create a new token named "Github Actions" and copy the value.
- In your repo settings, navigate to "Secrets and variables" > "Actions" and select "New repository secret"
- Create a secret with name "BUF_API_TOKEN" and paste the value of your token.
- Add another secret with name "BUF_USER" and provide your buf username.
Github packages is used for hosting an npm package of our generated code. A CI/CD pipeline is used to update this package with the latest generated code as changes are made to the API definitions. This npm package can then be used in frontend applications to consume the API.
- Navigate to the repository settings and select "Actions" > "General"
- Under Workflow permissions, select "Read and write permissions"
- Save the changes
To install the npm package, you must setup a .npmrc file in your project root with the following contents:
@jaebrownn:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken={YOUR_GITHUB_TOKEN}
This project uses Google Cloud Platform for hosting the backend services. The services are hosted on Cloud Run, and Cloud build is used to build the docker images and deploy the services. The docker images are stored in Artifact Registry.
- Create a Docker repository in Artifact Registry for storing your images for backend services. I have called this "services-artifacts"
- Setup a build trigger in Cloud Build to listen for changes to the backends, and build and deploy accordingly in line with the cloudbuild.yaml for the service. To do so, we must also connect our github repository to Cloud Build.
- Grant the necessary permission to deploy to cloud run by navigating to Settings and setting Service Account permissions as follows:

- Upon pushing changes to our hello-v1alpha1 backend, this trigger will automatically kick of the building and deploying of our service to cloud run
- TODO: you can set up your build triggers in different Google Projects to listen to specific branches. For example, a Production deployment that listens to the "main" branch, and a Development deployment that listens to the "dev" branch. This is useful for testing out changes before deploying to production.

