简体   繁体   中英

Firebase hosting deploy using service account created from different project

When I am deploying firebase hosting, even after passing with the project as an argument, it is trying to deploy firebase hosting to the project that the service account was created.

I have the GOOGLE_APPLICATION_CREDENTIALS set. It points to a service account created from another project (Shared service account for deployments), and it has Firebase App distribution admin and all required permissions on the current project.

./node_modules/.bin/firebase deploy --only hosting:$ENVIRONMENT --project ${PROJECT_NAME} --non-interactive

Error: HTTP Error: 403, Firebase Hosting API has not been used in project 49XXYYZZ628 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/firebasehosting.googleapis.com/overview?project=497XXYYZZ628 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

Of course, the project where the service account was created does not have API enabled.

How to force firebase to deploy the project passed with the firebase deployment command?

I have tried before the deploy command

gcloud config set project ${PROJECT_NAME}
firebase use --project ${PROJECT_NAME}

`

The steps I used to resolve the issue when using a service account from another project for firebase hosting deployment - from a clean CI-CD environment.

  1. Enable Firebase API on the project which the service account was created from.
  2. Below are commands to deploy if you have multiple apps with the targets.
 firebase use --add  <ProjectID> firebase target:apply hosting <TargetName> <TargetHostingName> firebase deploy --only hosting:<TargetName>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM