Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when deploying functions without .runtimeconfig.json #86

Open
sam-jg opened this issue Mar 9, 2021 · 12 comments
Open

Error when deploying functions without .runtimeconfig.json #86

sam-jg opened this issue Mar 9, 2021 · 12 comments

Comments

@sam-jg
Copy link

sam-jg commented Mar 9, 2021

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
Copy link
Author

sam-jg commented Mar 26, 2021

@w9jds any ideas?

@w9jds
Copy link
Owner

w9jds commented Mar 29, 2021

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

@sam-jg
Copy link
Author

sam-jg commented Apr 7, 2021

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?

@dayglo
Copy link

dayglo commented Apr 13, 2021

runtimeconfig.json is just for the emulator I think.

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

@calebdeji
Copy link

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

@calebdeji
Copy link

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.

@db-dblank
Copy link

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

@irby
Copy link
Contributor

irby commented Jul 18, 2021

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
Copy link
Contributor

irby commented Jul 19, 2021

@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

@weilinzung
Copy link
Contributor

weilinzung commented Oct 22, 2021

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
Copy link
Contributor

weilinzung commented Oct 22, 2021

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants