The Simplest Way to Make Gitea and Spanner Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running gitea and spanner together lets your team manage database changes through Git pull requests. Gitea hosts your code and runners, while Cloud Spanner stores your relational data at scale. This workflow keeps database updates tied to code reviews. Your runners read migration files from a repo and apply them to the target database. Without strict role scoping, Still, build jobs often hold way too much power. How gitea and spanner exchange identity and data Gitea manages source control, c

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.

Running gitea and spanner together lets your team manage database changes through Git pull requests. Gitea hosts your code and runners, while Cloud Spanner stores your relational data at scale.

This workflow keeps database updates tied to code reviews. Your runners read migration files from a repo and apply them to the target database. Without strict role scoping, Still, build jobs often hold way too much power.

How gitea and spanner exchange identity and data

Gitea manages source control, code review, and automated build pipelines. Spanner runs as a distributed SQL database on Google Cloud. To link them, a Gitea runner must log in to Google Cloud before sending queries.

Most teams set up workload identity federation or attach a service account to the runner. The runner exchanges its job token for a short cloud token. Then the migration tool uses that token to reach the Spanner API.

Once authenticated, the job sends schema updates or data queries over TLS. Cloud IAM checks whether the service account role allows those specific database actions. If the role matches, the database commits the change and returns a status code.

Teams also connect these tools when running Gitea itself on a cloud backend. In both cases, identity mappings decide which actor can read or write specific tables. Clear identity rules keep automated jobs from touching the wrong data.

Common failure modes and how to scope roles

The biggest risk in this setup is a static service account key stored in Git. If a developer copies that key, anyone with repo access can read production tables. Keys saved in build variables rarely rotate on time and often outlive their projects.

Another common issue is granting one broad role to all runners. A runner that only runs read tests does not need schema drop rights. When every repo shares one database identity, a single bad commit can break production.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged manual queries also create blind spots during an incident. Engineers often bypass slow Git pipelines to fix urgent data bugs by hand. When they use shared runner keys from their laptops, audit logs show only the generic bot.

To fix this, give each repo its own cloud service account. Grant fine-grained IAM roles that match the exact task, such as read-only for pull requests. Reserve write and schema change rights for protected main branch workflows.

You should also restrict network paths between your runners and your cloud project. Run your build agents inside a private network that reaches Google APIs through private routing. Combine network rules with data masking that rewrites emails, phone numbers, and card numbers in query results.

Auditing schema updates and ad-hoc database queries

Automated pipelines handle routine changes, but engineers still need direct database sessions for debugging. Relying on static cloud roles makes it hard to tie each query to a person. Teams need a clear record of every statement that runs against production tables.

Start by turning on data access logs in your cloud project for all database calls. Map every human user to their individual identity provider account instead of a shared role. Require peer approval before anyone runs a write query outside the main Git pipeline.

Separate your test instances from production databases at the project level. Let pull request checks run against throwaway databases with synthetic records. This setup catches bad migrations early and keeps real user records safe from test scripts.

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

Can Gitea use Cloud Spanner as its own backend database?

Gitea supports standard engines like PostgreSQL and MySQL out of the box. To use Spanner for Gitea metadata, you must use the PostgreSQL interface for Spanner and test compatibility.

How should Gitea runners log in to Spanner without static keys?

Use OpenID Connect tokens from your runner to federation endpoints in Google Cloud IAM. This approach trades the job token for temporary access and removes saved JSON keys.

How do we stop build jobs from reading sensitive customer columns?

Use fine-grained access control on tables and views to limit what the runner role reads. For human debugging sessions, apply dynamic masking to rewrite national IDs and emails in results.

The query runs. The emails stay hidden.