Start Building for Free

Deploy to Firebase

5 days ago1 min read
Server v4.x
Server v3.x
Server v2.x

This page provides a configuration for deployment to Firebase. In order to deploy to Firebase you will need to add firebase-tools to your project’s devDependencies since attempting to install firebase-tools globally in CircleCI will not work.

npm install --save-dev firebase-tools

Generate a Firebase CLI token using the following command:

firebase login:ci

Add the generated token to the CircleCI project’s environment variables as $FIREBASE_DEPLOY_TOKEN. To take advantage of secrets masking, it is best practice to set environment variables at the project level or within a context.

The following example shows how you can add a deploy to Firebase job to your project’s .circleci/config.yml file. This snippet assumes you already have a job to build your application, called build-job, and introduces a deployment workflow that only runs the deployment job once the build job has completed and you are on the main branch.

      - image: <docker-image-name-tag>
          username: mydockerhub-user
          password: $DOCKERHUB_PASSWORD  # context / project UI env-var reference
    working_directory: /tmp/my-project
      - run:
          name: Deploy Main to Firebase
          command: ./node_modules/.bin/firebase deploy --token=$FIREBASE_DEPLOY_TOKEN

  version: 2
      - build-job
      - deploy-job:
            - build-job
              only: main

If you are using Google Cloud Functions with Firebase, instruct CircleCI to navigate to the folder where the Google Cloud Functions are held (in this case 'functions') and run npm install by adding the below to .circleci/config.yml:

    - run: cd functions && npm install

Help make this document better

This guide, as well as the rest of our docs, are open source and available on GitHub. We welcome your contributions.

Need support?

Our support engineers are available to help with service issues, billing, or account related questions, and can help troubleshoot build configurations. Contact our support engineers by opening a ticket.

You can also visit our support site to find support articles, community forums, and training resources.