firebase-action icon indicating copy to clipboard operation
firebase-action copied to clipboard

Error when deploying functions without .runtimeconfig.json

Open sam-jg opened this issue 3 years ago • 12 comments

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?

sam-jg avatar Mar 09 '21 02:03 sam-jg

@w9jds any ideas?

sam-jg avatar Mar 26 '21 01:03 sam-jg

Sounds like you are using firebase configs in your functions and haven't set them properly. This isn't related to the action.

w9jds avatar Mar 29 '21 05:03 w9jds

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?

sam-jg avatar Apr 07 '21 20:04 sam-jg

runtimeconfig.json is just for the emulator I think.

When you run firebase functions:config:set the secrets are stored in firebase itself.

dayglo avatar Apr 13 '21 16:04 dayglo

@sam-jg , were you able to solve the issue?

calebdeji avatar Jun 20 '21 21:06 calebdeji

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 avatar Jun 21 '21 13:06 calebdeji

@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.

db-dblank avatar Jul 06 '21 03:07 db-dblank

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

irby avatar Jul 18 '21 18:07 irby

@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

irby avatar Jul 19 '21 15:07 irby

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.

weilinzung avatar Oct 22 '21 12:10 weilinzung

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

weilinzung avatar Oct 22 '21 15:10 weilinzung

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.

weilinzung avatar Oct 22 '21 21:10 weilinzung