The Simplest Way to Make GCP Secret Manager and Github Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair gcp secret manager and github to pull secret values during build jobs. This setup lets automated workflows read database passwords and API keys without storing static files. In the past, engineers copied cloud keys into repo settings by hand. That old habit created stale credentials that were hard to track or rotate. Today, modern identity links let both platforms trust each other using short-lived tokens. How gcp secret manager and github exchange identity and data The link betwe

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.

Teams pair gcp secret manager and github to pull secret values during build jobs. This setup lets automated workflows read database passwords and API keys without storing static files.

In the past, engineers copied cloud keys into repo settings by hand. That old habit created stale credentials that were hard to track or rotate. Today, modern identity links let both platforms trust each other using short-lived tokens.

How gcp secret manager and github exchange identity and data

The link between gcp secret manager and github relies on OpenID Connect and Workload Identity Federation. When a workflow starts, the code host creates a signed identity token for that job. This token states the repo name, branch, and workflow actor.

Google Cloud checks this signed token against a pool of trusted providers. If the token claims match your trust rules, Google Cloud returns a temporary token. The runner then uses that temporary token to request specific secret versions.

Permissions flow through cloud IAM roles rather than repo secret stores. You grant the secret accessor role to a specific cloud service account. Then you let only matching repo claims act as that service account. The secret value travels over TLS right into the runner memory for that single step.

Common failure modes and how to scope roles

Many teams still make mistakes when they set up this trust link. The worst mistake is using a single shared service account for every repo. If one test workflow gets compromised, the attacker can read every production secret.

Another common risk comes from broad attribute conditions in the cloud identity pool. If you check only the owner name, any forked repo or side project might pass. You must lock the condition down to the exact repo name and branch ref.

GCP Secret Manager + GitHub Secret Scanning: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged secret reads also create blind spots during security audits. You should turn on data read logs in Google Cloud to track every secret fetch. These logs show which workflow run asked for which secret version and when.

To scope roles well, put secrets for different stages into separate cloud projects. Give each production repo its own service account with read rights to single secrets. Never grant project-wide secret access to a build runner.

Managing runtime database and cloud sessions beyond build jobs

Pulling secrets into a runner solves only part of the security puzzle. Once a job or developer has a raw database password, cloud IAM stops watching. The cloud log shows the secret read, but not the queries that follow.

Engineers also need a safe way to run ad-hoc checks against live systems. Giving staff direct read rights to the secret store exposes raw credentials on laptops. Teams need fine-grained controls that work at the command and query level.

Strong security setups separate secret storage from live session execution. Workflows and staff should log in with their own identities before they run any command. Adding field masking can also rewrite emails, phone numbers, and card numbers in query results.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How do we connect GitHub Actions to GCP Secret Manager without static keys?

Use Google Cloud Workload Identity Federation with the GitHub OpenID Connect provider. The workflow trades its job token for a short-lived cloud token at runtime.

How should we scope IAM roles for secret access?

Grant the secret accessor role on individual secrets instead of the whole project. Bind that role to a dedicated service account for one repo and branch.

What happens if a secret value prints in build logs?

Most runners mask known secret strings in log output by default. Still, if a script transforms or encodes the value, it can still leak into plain text.

The query runs. The emails stay hidden.