The Simplest Way to Make Cloud Run and GitHub Actions Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using cloud run and github actions together lets teams build and ship container apps fast. Code changes in your repo trigger runners that build images and update your live service. This workflow cuts out manual steps for your team. Developers push code, and the pipeline handles the rest. Yet connecting these two platforms takes careful planning around keys, roles, and logs. Without clear rules, teams often leave broad keys sitting in repo settings. How cloud run and github actions handle logi

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 actions together lets teams build and ship container apps fast. Code changes in your repo trigger runners that build images and update your live service.

This workflow cuts out manual steps for your team. Developers push code, and the pipeline handles the rest. Yet connecting these two platforms takes careful planning around keys, roles, and logs. Without clear rules, teams often leave broad keys sitting in repo settings.

How cloud run and github actions handle login and data flow

First, the runner needs a safe way to log in to Google Cloud. In the past, teams exported static JSON keys and saved them as repo secrets. Static keys never expire on their own, which creates a big risk for your cloud account.

A safer path uses federated identity between the two platforms. When a job starts, the runner asks for a temporary ID token. Google Cloud checks this token against a trust rule you set up in advance. If the repo and branch match your rule, the cloud issues a short-lived token.

Next, the runner uses that token to push a container image to the registry. Once the upload finishes, the workflow tells the container service to deploy the new image. The service pulls the image, starts new instances, and shifts web traffic over. Data flows in one clear line from source code to the live app.

Common failure modes and how to scope roles

Many teams hit trouble when they share one service account across every repo. If one workflow gets compromised, an attacker can touch every app in that cloud project. Overbroad roles make this problem much worse. Giving a build runner full editor rights lets it read private buckets or drop databases.

Unlogged actions also hurt teams during an audit or outage. When five repos use the same bot identity, cloud logs cannot show who triggered a bad release. You see the bot name in the log, not the person or the specific workflow run.

GitHub Actions Security + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, create one dedicated service account for each app or repo. Grant that account only the exact rights it needs to do its job. It needs permission to write to the image registry and update one specific service. It also needs permission to act as the runtime identity of that single app.

You should also lock down the trust rule by branch or tag. Only allow the main branch or release tags to push changes to production. Pull requests from forks should only run tests, and they should never get cloud tokens. Network rules matter too, especially when runners need to reach private cloud networks.

Keeping manual tasks and database updates safe

Pipelines work well for standard code releases, but teams still run manual tasks. Sometimes an engineer needs to run a database migration or check live data during an incident. Putting database passwords into workflow secrets or sharing them with staff creates new risks.

Treat one-off tasks with the same care as your automated builds. Every command against a live system should link back to a real person. Teams need clear logs of what ran, plus rules that protect sensitive data like emails or card numbers.

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 Google Cloud JSON keys in my repo secrets?

No, static JSON keys stay valid until someone deletes them by hand. Use federated identity instead so the runner gets a fresh, temporary token for each job.

How do I stop pull requests from deploying to production?

Add an attribute condition to your cloud identity pool. Set the rule so only jobs from your main branch can trade their token for cloud access.

What roles does the build runner actually need?

The runner needs rights to push images to your registry and deploy to the container service. It also needs permission to attach the runtime service account to the app.

The query runs. The emails stay hidden.