Is there any way I can automate my "firebase deploy" pushes to Firebase Hosting using a script? I can't seem to figure out how to do this.
Thanks.
Here's a couple different approaches:
Firebase's own David East on how to do it with Travis and GitHub
https://www.youtube.com/watch?v=QLVzozWDYAs
I took an alternate approach, since my automation tool is written in java.
firebase CLI installed in the bash shell, previous to launching my java binary.
[deploy.sh] shell script runs "firebase deploy" command.
java binary has internal code to run the [deploy.sh] script.
Bottom line - no matter what your automation binary is written in, as long as it can shell out and run your [deploy.sh] script in the same shell that firebase is installed in, you should be good to go.
Open your terminal and run this command to generate a new CI token. this will help a lot if you are deploying your project on GitHub
npm install -g firebase-tools
firebase deploy --non-interactive --token $FIREBASE_TOKEN
to complete the automation process
firebase login:ci
personal suggestion: click here to see steps of using all commands
Related
when I running fireabse. i am running the following command :
"serve": "firebase use dev && firebase emulators:start --import=./emulator-data"
i have added data but I can not now save the data to the emulator
and I have got :
Error: Did not find any running emulators for project test-dev.
the command that i run is :
firebase emulators:export ./emulator-data
how can I fixed it ?
i verified the project is connected on gcloud and everything was working as it should
In order to troubleshoot this error you can follow the following steps as mentioned in Github_issue
ran sudo firebase emulators:export ./exported and got a new error
file not found!!
control c the running firebase process then ran it
again and got the same file not found error!!
command quit both
terminal windows
deleted the log files
ran the firebase emulator
again with "sudo firebase emulators:start --import ./data
--export-on-exit" (works)
opened another terminal window and "sudo firebase emulators:export ./exported" and it worked!!
Sometimes this issue can occur due to installations of firebase-tools path and npm and node paths are different. You may have a look at the link.
For additional information on emulators, you can follow the firebase documentation.
My .gitlab-ci.yml needs to call not only the gcloud cli but also firebase cli.
The image: google/cloud-sdk:latest allows me to call the gcloud cli but not the firebase cli.
The image: devillex/docker-firebase allows me to call the firebase cli but not the gcloud cli.
I've tried installing the firebase CLI by following firebase's CI/CD instructions but I got an error about permissions which seemingly required sudo. However, gitlab doesn't even offer sudo, not surprisingly.
I've tried searching the stackoverflow and hub.docker.com but I can't find an image that offers both CLIs. Do you know of one that offers both?
Is there somewhere else I can search or some way to search differently (e.g. are certain keywords helpful in searching for a docker image)?
If I wanted to try to combine image: google/cloud-sdk:latest and image: devillex/docker-firebase into one image, how would I do that? What's the first step? I've never made a Docker image let alone tried to merge two existing ones.
You can base your docker image on google/cloud-sdk:alpine, and then install npm and use it to install firebase tools:
FROM google/cloud-sdk:alpine AS base
RUN apk add --update npm
RUN npm install -g firebase-tools
I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json
What I want to acheieve
So using Cloud Run, I wanted to achieve as below
Firebase Cloud Function(FCF) invoked
FCF makes a call to the other API service and fetch a certain value {bar:baz}
FCF makes a call to Cloud Run endpoint with the value as params
Cloud Run that was built and deployed with Docker Image of Firebase CLI gets triggered
in Cloud Run, it executes the commands firebase functions:config:set foo.bar=baz
Successfully updates FCF environment variables as foo.bar=baz
Issues
so previously asked here, Google Cloud Run - Run Shell Script in firebase project and with the solutions that were provided by #guillaume blaquiere, I finally got to the point where I run commands like firebase --version or firebase projects:list and they worked fine as the information is printed out on the browser.
However, when I run the commands like firebase use project test123 or firebase functions:config:set foo.bar=baz, Cloud Run throws the error exec error: exit status 1
Source Code
# Dockerfile
FROM node
RUN npm i -g firebase-tools
ADD my_script.sh /
COPY --from=msoap/shell2http /app/shell2http /shell2http
RUN chmod +x my_script.sh
ENTRYPOINT ["/shell2http","-export-all-vars"]
CMD ["/update","/my_script.sh"]
#my_script.sh
#!/bin/sh
firebase --token $TOKEN use foobarbaz-123
firebase functions:config:set foo.bar=baz
when build image with gcb
gcloud builds submit --tag gcr.io/foobarbaz-123/testbash
when deploy
gcloud run deploy --image gcr.io/foobarbaz-123/testbash --platform managed
or deploy with token that I get from firebase login:ci
gcloud run deploy --image gcr.io/foobarbaz-123/testbash --platform managed --set-env-vars=TOKEN=foobarbaz12345
where do I need to fix? Any advices or suggestions will be appreciated
I am trying to run a "firebase init functions" in android studio terminal but it is showing firebase command not found. I have also checked in google but unfortunately did not find any related question or answer.
Seems like you haven't installed firebase tools .to do so type this in your terminal
First install node js from nodejs.org
npm install -g firebase-tools
Now you can login using firebase login and after login you can now run firebase init