Repository navigation
Add support for Build Envvars and Secrets - #11266
Merged
Merged
Conversation
Reads the firebase.google.com/buildConfig.environmentVariablesAndSecrets annotation on the service. Plain values go to Cloud Build and local builds; secret references only work in local builds, which read them with the deployer's credentials.
Realistic names (API_URL, NPM_TOKEN, npm-token) and shorter fixtures.
# Conflicts: # src/deploy/run/deploy.spec.ts # src/deploy/run/prepare.spec.ts
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for build-time environment variables and secret references on Cloud Run services by reading them from a service annotation, validating them, and passing them to either Cloud Build or local builds. The review feedback highlights two TypeScript type-safety issues: first, an unsafe type assertion (as Record<string, string>) in deploy.ts should be replaced with explicit filtering of string values to adhere to the repository style guide; second, a compilation error in buildEnv.ts when calling Object.entries on an unknown type should be resolved by casting the validated object to Record<string, unknown>.
falahat
added this pull request to stack #11267
October 12, 2026 15:22
# Conflicts: # src/deploy/run/deploy.ts
# Conflicts: # src/deploy/run/args.ts
falahat
commented
Oct 13, 2026
A build secret is now written the way apphosting.yaml writes one ({"secret": "npm-token@3"}) and passed straight to loadSecret, so there are no extra regexes or format conversions. Cloud Build gets an explicit filter for plain values instead of a cast, and the comments and errors say why only local builds can use secrets.
The name and doc comment now say that the result never includes secrets or their values.
abhis3
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Lets Cloud Run deployments pass env vars and secrets to the build. They're read from the service's
firebase.google.com/buildConfig.environmentVariablesAndSecretsannotation, a JSON object. The annotation is a prototype: where this config finally lives is out of scope for now.Values follow apphosting.yaml:
3becomes"3"), as they do in apphosting.yaml.{"secret": "npm-token"},{"secret": "npm-token@3"}, or a full resource name.Only local builds can use secrets: they read them with the deployer's credentials, through App Hosting's
loadSecret. Cloud Run's build API only takes plain values, so if the annotation names a secret, a deploy that builds on Cloud Build fails and points to"localBuild": true. Per the spec, there's no--allow-local-build-secretsflag.buildEnv.ts: parses and validates the annotation.prepare.ts: reads it, and rejects secrets for builds on Cloud Build.deploy.ts: passes only the non-secret values to Cloud Build, and all of them to local builds.Stacked on #11207. Next is #11208 (SDK auto-init).
Scenarios Tested
Sample Commands