Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use 'firebase login:ci' on a build server

I am running a nodejs build using Github Workflows and I want to be able to build my project and then immediately deploy it to my firebase project. Using firebase deploy. But if I want to use the firebase-tools I have to login on the build server. But there isn't a way to get authenticated via email and password etc. Is there anyway to enable me to get what I want to accomplish done? firebase-tools Inside my build script is "react-scripts build && firebase deploy"


This is my workflow file, nodejs.yml:


name: Node CI

on: [push]

jobs:
  build:

runs-on: ubuntu-latest

strategy:
  matrix:
    node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
  uses: actions/setup-node@v1
  with:
    node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
  run: |
    npm i -g firebase-tools
    firebase login
    npm ci
    npm run build --if-present
    npm test
  env:
    CI: true
like image 764
tdmiller Avatar asked Nov 14 '19 01:11

tdmiller


People also ask

Does firebase have CI CD?

Firebase Continuous Integration and Deployment (CI/CD) with Google Cloud Build. In this December month article, I'll be walking you through the CI/CD of Firebase with Google Cloud Build.

What is CI firebase?

You can use Firebase Test Lab when developing your app using any continuous integration (CI) system. Continuous integration systems let you automatically build and test your app each time you check in updates to your app source code.

What does firebase init do?

The firebase init command creates a firebase. json configuration file in the root of your project directory. The firebase. json file is required to deploy assets with the Firebase CLI because it specifies which files and settings from your project directory are deployed to your Firebase project.

Which command is used for deploying a firebase hosted application?

Using the Firebase CLI, you deploy files from local directories on your computer to our Hosting servers. Beyond serving static content, you can use Cloud Functions for Firebase or Cloud Run to serve dynamic content and host microservices on your sites.


1 Answers

You don't have to use firebase login on the CI system. All you have to do is follow the instructions in the documentation to integrate with any CI system.

Use the CLI with CI systems

The Firebase CLI requires a browser to complete authentication, but the CLI is fully compatible with CI and other headless environments.

  1. On a machine with a browser, install the Firebase CLI.

  2. Start the signin process by running the following command:

  3. firebase login:ci

  4. Visit the URL provided, then sign in using a Google account.

  5. Print a new refresh token. The current CLI session will not be affected.

  6. Store the output token in a secure but accessible way in your CI system.

  7. Use this token when running firebase commands. You can use either of the following two options:

    • Store the token as the environment variable FIREBASE_TOKEN. Your system will automatically use the token.

    • Run all firebase commands with the --token flag in your CI system. The order of precedence for token loading is flag, environment variable, desired Firebase project.

like image 54
Doug Stevenson Avatar answered Nov 15 '22 06:11

Doug Stevenson