The Simplest Way to Make Cloud Run and Github Work Like They Should
Using cloud run and github lets teams build code and deploy containers fast. You push code to a branch, and a runner ships your container image. This workflow turns code changes into live apps within minutes. Still, fast deploys need tight rules for keys, roles, and logs. When teams skip these rules, one bad push can break production. A clean setup keeps both platforms safe and easy to run. How cloud run and github share identity and data Your code lives in a repo, and your app runs in Googl
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Using cloud run and github lets teams build code and deploy containers fast. You push code to a branch, and a runner ships your container image.
This workflow turns code changes into live apps within minutes. Still, fast deploys need tight rules for keys, roles, and logs. When teams skip these rules, one bad push can break production. A clean setup keeps both platforms safe and easy to run.
How cloud run and github share identity and data
Your code lives in a repo, and your app runs in Google Cloud. When a developer merges a pull request, a build job starts right away. That job packages your app into a container image. Next, the job sends the image to a cloud registry. Then it tells the runtime service to launch a new revision.
To do this work, the build runner must prove who it is. Good teams skip static keys and use OpenID Connect instead. The repo host sends a signed token to Google Cloud. Google checks the token against a trust rule you set up. If the repo and branch match your rule, the runner gets a role. This temporary role lasts only for the length of the build job.
Data flows in one clear direction during this process. Source files and build logs stay inside the repo platform. Container images and runtime metrics live in the cloud project. You should also think about what data enters your build logs. If an app prints user emails or phone numbers, scrub those logs first. Masking tools can rewrite card numbers and national IDs in query results.
Common failure modes and how to scope roles
Many teams start with a single shared service account for all builds. They download a static JSON key and paste it into repo secrets. This shortcut creates a huge risk for your whole cloud project. Static keys do not expire unless you delete them by hand. If a key leaks, an attacker can use it from any machine.
Broad roles cause another common problem in this workflow. Teams often grant editor or owner roles to fix a permission error fast. Then a build job in one small repo can delete other production services. Unlogged actions make this worse when developers also run manual deploys from laptops. When two people push changes at once, nobody knows what broke the app.
GitHub Actions Security + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these issues by scoping each role to one task. Give each repo its own service account in Google Cloud. Grant only the permission to push images and update one specific service. Restrict the identity pool so only your main branch can trigger production deploys. Pull requests from forks should only run tests and never touch cloud resources.
Network paths between the two systems also need clear boundaries. Your build runner needs to reach the cloud API to deploy the container. If the runner also runs database migrations, keep the database off public networks. Use private network paths and tight firewall rules for every backend step. Keep runtime roles separate from deploy roles at all times. The container that serves users does not need permission to deploy code.
Keeping runtime operations safe after the deploy
Shipping the container is only half of the daily workflow. Once the service runs, engineers still need to check logs and fix bugs. Teams often share broad cloud roles so engineers can inspect live containers. That habit brings back the exact risks you removed from your build pipeline.
Treat human tasks with the same strict rules you use for automated builds. Tie every action to a real person instead of a shared team account. Keep a clear log of every command and query run against live systems. When you match tight build rules with safe runtime habits, your setup stays clean.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Should I store a Google Cloud JSON key in my repo secrets?
No, you should avoid static JSON keys in your repo secrets. Use Workload Identity Federation so the runner gets a short token for each run.
How do I stop pull requests from deploying to production?
Set attribute rules on your cloud identity pool to check the branch name. Allow only tokens from your main branch to assume the production deploy role.
Should the build runner and the running container share one service account?
No, give the build runner and the live container separate service accounts. The runner needs deploy permissions, while the live app only needs runtime permissions.
Related guides
In this post