firebase-action
firebase-action copied to clipboard
Error when deploying functions without .runtimeconfig.json
I get the following error when deploying from github using this action.
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'db_host' of undefined
I assume the error is because there is no .runtimeconfig.json
file committed to the repo and therefore not accessible to the action. I can't commit the file, because it contains secrets.
Is there any recommended work around for this?
@w9jds any ideas?
Sounds like you are using firebase configs in your functions and haven't set them properly. This isn't related to the action.
The are definitely setup properly as I have no problems deploying from my local machine. I guess this is more of a usage question than a bug or error. How am I meant to deploy functions with this action when I cannot commit the .runtimeconfig.json
file because it contains secrets?
runtimeconfig.json is just for the emulator I think.
When you run firebase functions:config:set
the secrets are stored in firebase itself.
@sam-jg , were you able to solve the issue?
This is probably late but if you still need an answer to this. You can pass your argument as
functions:config:set env=\"$(cat functions/env.json)\"
It's not advisable to push your env.json
, you can use this action to create the env.json on your CI.
@calebdeji How would I set the functions config and deploy at the same time?
args: functions:config:set foo="bar" deploy --only functions
This is not working for me.
You may need to chain your requests, you can't set the args and deploy at the same time, you'll get a key=value error from the Firebase CLI
@db-dblank Use the following to simultaneously set your environment variables and deploy your function
args: functions:config:set ${{ secrets.FIREBASE_FUNCTIONS_ENV_VARIABLES }} ; firebase deploy --only functions
Can we have an extra step to fetch the config into a JSON then start to deploy?
similar to Storing GCP_SA_KEY in /opt/gcp_key.json
functions:config:get > .runtimeconfig.json
It doesn't make sense to save as secrets because the config variables could be updated/unset from local and doing config:set
with this action would overwrite the variable again.
This is the action log, and 'rumtimeconfig' that shouldn't be required for deploy. It is strange.
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> lint
> eslint "src/**/*"
Running command: npm --prefix "$RESOURCE_DIR" run build
> build
> tsc
✔ functions: Finished running predeploy script.
i functions: ensuring required API cloudfunctions.googleapis.com is enabled...
i functions: ensuring required API cloudbuild.googleapis.com is enabled...
✔ functions: required API cloudbuild.googleapis.com is enabled
✔ functions: required API cloudfunctions.googleapis.com is enabled
Error: Error occurred while parsing your function triggers.
TypeError: Cannot read property 'client_id' of undefined
....
The client_id
is using like this functions.config().env.client_id
We fixed it by adding Firebase Admin
for function deployment. If the role is not set properly, undefined
because request config() in the runtime.
We got confused about the Firebase Admin
and Firebase Hosting Admin
roles for the service account.