I have a CI pipeline to deploy my firebase changes to different environments. (dev, test, prod)
Currently, it works by running firebase deploy --token $FIREBASE_TOKEN command.
I have generated $FIREBASE_TOKEN by running firebase login:ci from my admin account which has access to all projects (dev, test, prod).
Now if someone gets access to dev CI he/she can deploy directly to production reusing the same $FIREBASE_TOKEN token.
How can I authenticate per firebase project to generate 3 separate tokens for each environment?
Related
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.
Enable Firebase API on the project which the service account was created from.
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>
In the project I'm currently working on, I have set up Firebase hosting and cloud functions.
I thought that I could only deploy functions like this: firebase deploy --only hosting --token %FIREBASE_TOKEN% However, when I run the command it also deploys the cloud functions. Am I doing something wrong? How can I deploy ONLY the changes I've made in hosting without re-deploying the cloud functions.
Thank you!
I have a firebase project setup and I want to use that same project for both an iOS app and to host a website.
I built a basic iOS app.
On my desktop I have a folder:
myiosproject
- iOS
- firebase
- functions
- index.js
I followed the steps to setup cloud functions which according to the docs are to npm install firebase tools, firebase init and then firebase deploy. I've deployed my code to cloud functions and that works fine.
I've also built a basic website and would like to deploy that to firebase hosting. On my desktop I have a folder:
myWebsite
- images
- index.html
According to the hosting docs the process to set up and deploy is the same as for cloud functions: npm install, firebase init, firebase deploy.
So my question is how does firebase "know" if I am running firebase deploy from my website folder in which case the code should go to hosting or whether I am deploying from my firebase functions folder in which case the code should go to firebase cloud functions?
If you use the Firebase CLI to create your project (https://firebase.google.com/docs/hosting/quickstart) your project will organize your code by default, separating the files to be used for hosting under a "public" directory and the source code for Cloud Functions under a "functions" directory.
Then you can choose to deploy only the hosting
firebase deploy --only hosting
or only the functions:
firebase deploy --only functions
Have a look at the detailed CLI documentation: https://firebase.google.com/docs/cli/
According to the docs:
firebase-deploy
it deploys the following:
New releases of your Firebase Hosting sites
New or existing Cloud Functions
Rules for Firebase Realtime Database
Rules for Cloud Storage
Rules for Cloud Firestore
Indexes for Cloud Firestore
if you only want to deploy specific features, you can do the following:
firebase deploy --only hosting <-- for hosting
firebase deploy --only functions <-- for cloud functions
Question
How can I deploy my Firebase site without erasing Cloud Functions.
Maybe, include both site and cloud-functions in one deploy? What does that look like?
Maybe, deploy the site without erasing cloud-functions? I don't find a firebase deploy --only site or similar
Context
I have a Firebase project that uses Cloud Functions. The code is in two folders:
-site-code
-cloud_function-code
When I want to deploy the project, I use firebase CLI tools, in two steps:
Step 1
from -site-code I run:
firebase deploy
Step 2
then from cloud_functions-code I run:
firebase deploy --only functions
Issue
When I run firebase deploy from -site-code, my Firebase Cloud Functions are deleted, so I must follow up with firebase deploy --only functions from -cloud_functions-code.
I did not find an --only directive for deploying just the site code from -site-code
To only deploy your web site, use
firebase deploy --only hosting
The Firebase CLI provides a way to deploy single functions as shown in its documentation:
firebase deploy --only functions:name_of_function
I'd like to be able to deploy an individual Cloud Function for Firebase so I don't have to deploy my entire project every time.
There isn't an option through the CLI, but if there's a rest API or some other interface that Google or Firebase exposes to make this easier, that would be great.
The CLI provides the capability to deploy a single function:
firebase deploy --only functions:myFunction
or list of functions:
firebase deploy --only functions:myFuncA,functions:myFuncB,functions:myFuncC
For more details:
firebase deploy --help