Samaila Bala I'm a frontend engineer and technical writer.

Setting up continuous deployment with React, Firebase, and GitHub Actions

3 min read 1027

Setting Up Continuous Deployment With React, Firebase, and GitHub Actions

Automating your deployment process helps you deliver your product faster and allows your team to focus on building and collecting valuable feedback from customers.

Continuous deployment (CD), not to be confused with continuous delivery, is a software engineering approach in which software functionalities are delivered frequently through automated deployments. Continuous delivery, by contrast, needs final approval before a manual deployment is triggered.

Firebase is a web and mobile development platform by Google that includes offerings such as hosting, realtime database, and cloud storage. This tutorial will focus on the hosting product.

Setting up continuous delivery is sometimes a chore because you often have to use different tools and platforms to set up, build, test, and deploy — which brings us to GitHub Actions.

Launched in November 2019, GitHub Actions are individual tasks that you can combine to create jobs and customize your workflow. Most importantly, it enables you to set up tasks to build, test, and deploy your code from GitHub to Firebase.

In this guide, we’ll show you how to set up a workflow that builds, tests, and deploys a sample React project to Firebase.


To follow along with this tutorial, you should be familiar with the following.

  • JavaScript
  • React
  • Git
  • Terminal (Mac/Linux)/Command prompt (Windows)

Setting up a React project

We’ll use Create React App to get our React app up and running. Run the following commands in your terminal to set up a sample React app.

npx create-react-app react-cd-sample
cd react-cd-sample
npm start

Setting up a Firebase project

To set up a firebase account, go to Firebase Console, click on “Create a project,” and fill in the details.

Firebase console

After setting up the project, you should see a dashboard similar to the screenshot below. Add a web app on the dashboard and fill in the details.

Firebase Dashboard

Once you’re done, launch your terminal and run the command below to install the firebase-cli globally.

npm install -g firebase-tools

Firebase CLI is a tool for managing, viewing, and deploying Firebase projects.

The next step is to initialize Firebase in the React project you created. Navigate to the root of your project on your terminal and run the command to log in to Firebase.

firebase login:ci

The above command will launch your browser and open a Google authentication page. After a successful authentication, a token will display on your terminal. Copy it and keep in a safe place because you’ll need it when it comes time to create a workflow.

After successful authentication, run the following.

firebase init

This initializes firebase and allows you to choose the products you want to integrate into your React project. As noted earlier, for this tutorial we’ll focus on hosting.

Firebase Project Directory

After choosing hosting, you’ll be prompted to configure the hosting options.

  1. Input build as the public directory since that’s the default directory React serves after building a project
  2. Input No on the configure as a single-page app prompt to allow React to control that behavior

Firebase Hosting Configuration

If it prompts you to overwrite any files, input no since you don’t want it to rewrite files generated by React. After the process is complete, two files are generated: firebase.json and .firebaserc.

The firebase.json file contains information on the location of files, assets, and settings related to the project. The .firebaserc file stores project aliases, which can be used to set different hosting options for the same application — one for staging and the other for production.

Creating a workflow

We’ll use a GitHub action created by Jeremy Shore called GitHub Action for Firebase, which wraps the firebase-cli to enable common commands.

To get started, you’ll need a GitHub repository to house your project, so head over to GitHub and create one. Add the repository to the project, commit the changes, and push the project to GitHub.

Next, go to your settings in the repository and click on Secrets, then Add a new secret. Input FIREBASE_TOKEN as the name and the token you copied earlier as the value. After doing that, click Add secret to save the environment variable.

To create a workflow, the workflow file must be stored in a .github/workflows directory located in the root directory of your project. Go to the root of your project directory and run the following.

More great articles from LogRocket:

mkdir .github
cd .github
mkdir workflows
cd workflows
touch main.yml

Open main.yml in a text editor and input the following.

name: Firebase Deploy
      - master
    name: Build
    runs-on: ubuntu-latest
      - name: Checkout Repo
        uses: actions/[email protected]
      - name: Install Dependencies
        run: npm install
      - name: Run Tests
          CI: true
        run: npm test
      - name: Build
        run: npm run build
      - name: Archive Production Artifact
        uses: actions/[email protected]
          name: build
          path: build
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
      - name: Checkout Repo
        uses: actions/[email protected]
      - name: Download Artifact
        uses: actions/[email protected]
          name: build
          path: build
      - name: Deploy to Firebase
        uses: w9jds/[email protected]
          args: deploy --only hosting
          FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}

The workflow is divided into two main parts: on and jobs. The on section defines what triggers the workflow — in this case, whenever you push to the master branch. The jobs section defines what the workflow is expected to run, which is build and deploy. Build installs the dependencies, runs test, and builds the project. Deploy is dependent on build; after the build job runs successfully, deploy is responsible for deploying the project to firebase.

Deploying to Firebase

After saving the file, commit and push your changes to GitHub. Click on the Actions tab on the repository and watch the actions as it runs. Once it successfully executes, the project is deployed to Firebase. Visit your to view your project.


Setting up continuous deployment doesn’t have to be expensive or cumbersome. You can integrate the processes described in this tutorial into your projects with ease, and it’ll help ensure you deploy projects with fewer bugs to production more quickly than ever before.

To learn more, check out the following resources.


Get setup with LogRocket's modern React error tracking in minutes:

  1. Visit to get an app ID.
  2. Install LogRocket via NPM or script tag. LogRocket.init() must be called client-side, not server-side.
  3. $ npm i --save logrocket 

    // Code:

    import LogRocket from 'logrocket';
    Add to your HTML:

    <script src=""></script>
    <script>window.LogRocket && window.LogRocket.init('app/id');</script>
  4. (Optional) Install plugins for deeper integrations with your stack:
    • Redux middleware
    • ngrx middleware
    • Vuex plugin
Get started now
Samaila Bala I'm a frontend engineer and technical writer.

9 Replies to “Setting up continuous deployment with React, Firebase, and GitHub…”

  1. Yes you can, all you have to do is modify the flag in `args` of the deploy job to `–only functions,hosting`

  2. Input FIREBASE_TOKEN as the name and the token you copied earlier as the value. After doing that, click Add secret to save the environment variable.

    what is the copied value? is it Firebase-Api-Key or something else. I didn’t get it

  3. Thanks a lot for that! For those people who are a bit confused

    Ensure the branch is “master” or “main”
    repoToken: ‘${{ secrets.GITHUB_TOKEN }}’
    firebaseServiceAccount: ‘${{ secrets.FIREBASE_SERVICE_ACCOUNT_[your project name] }}’

    that’s how it worked for me

Leave a Reply