The Simplest Way to Make Firestore and Github Work Like They Should
Teams pair Firestore and GitHub to track database rules and automate deployments from code repos. This setup lets developers test and push schema changes, indexes, and security rules through pull requests. By storing rules in version control, teams review every database change before it goes live. Automated workflows then run tests and push approved updates straight to the cloud project. How Firestore and GitHub share permissions and data GitHub stores your database rules, index definitions,
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 Firestore and GitHub to track database rules and automate deployments from code repos. This setup lets developers test and push schema changes, indexes, and security rules through pull requests.
By storing rules in version control, teams review every database change before it goes live. Automated workflows then run tests and push approved updates straight to the cloud project.
How Firestore and GitHub share permissions and data
GitHub stores your database rules, index definitions, and app code in a central repo. When a developer opens a pull request, automated runners start a test workflow.
The workflow needs permission to talk to your Google Cloud project and update the database. In the past, teams created static service account keys and saved them as repo secrets.
A better way uses OpenID Connect to link your code workflows with Google Cloud IAM. The runner requests a short-lived token from Google Cloud at the start of each job.
Google Cloud checks the repo name, branch, and workflow identity before it grants any permission. Once approved, the runner pushes the new rules or indexes to the database.
Data also flows back to the repo during automated backups or schema checks. Scheduled jobs can export collection data to cloud storage buckets and log the status in commits.
Common failure modes and how to scope roles
The biggest risk in this setup comes from broad service accounts and static JSON keys. If a long-lived key leaks from a repo, attackers gain full control over your data.
Teams often grant the owner or editor role to the deployment runner by mistake. That broad role lets a broken script delete collections or overwrite live customer records.
Another failure happens when developers run ad-hoc database scripts from their laptops or shared runners. These manual queries often bypass peer review and leave no clear user log behind.
GitHub Actions Security + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
When five engineers share one service account, audit logs cannot show who ran a bad write. You see the shared bot name in the log, not the person who triggered it.
To fix this, give each workflow a narrow role that matches its exact task. A job that updates security rules should never have permission to read customer documents.
Split your staging and production projects so test branches cannot touch live data. Set trust conditions on your cloud identity pool to allow pushes only from the main branch.
You should also require human approval in the code platform before any production job runs. For sensitive data, mask fields like emails, phone numbers, and card numbers in query results.
Testing database rules in automated pipelines
Writing security rules by hand often leads to open collections or broken app features. You can catch these mistakes early by running local emulator tests inside your pull requests.
When a developer changes a rule file, the workflow boots a temporary database emulator. The test suite then tries to read and write documents using different mock user roles.
If an unauthenticated user can read private records, the test fails and blocks the merge. This check keeps bad rules out of production and gives reviewers confidence in every change.
Once all checks pass and a teammate approves the code, the main branch workflow takes over. It deploys the verified rules to the live database and records the commit hash.
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
How do I deploy Firestore rules from GitHub without JSON keys?
Use Workload Identity Federation between Google Cloud and your repo workflows. This trust relationship trades a workflow token for a short-lived cloud token during the job run.
What IAM role does a GitHub runner need for Firestore?
Grant only the specific role needed to update rules and indexes, not full project editor rights. Keep data read and write roles separate from rule deployment roles.
Can I test Firestore security rules in pull requests?
Yes, your workflow can start the local database emulator during a pull request check. Run your unit tests against the emulator to verify read and write rules before merging.
Related guides
In this post