ArchiveAbout

Kyle Pericak

"It works in my environment"

Created: 2020-01-16Updated: 2020-01-16

CircleCI: Continuous Delivery for Firebase

Category:developmentTags:firebase;
A very simple CD setup for a basic hosting Firebase app.

Table of Contents

Create CI token

This will do the usual browser-based login system, so if you're using a VM then be sure your lolcahost:9005 goes to the server's :9005.

firebase login:ci

Add token as CircleCI env var

  1. Log into CircleCI
  2. Choose your GitHub project
  3. Use the Hello World build template
  4. Assign that token as $FIREBASE_DEPLOY_TOKEN in the project's environment variable settings.
    1. Navigate to your project in CircleCI
    2. Click the gear on the top-right to open this project's settings
    3. Open environment variables page
    4. Add Variable. Name: FIREBASE_DEPLOY_TOKEN, value is your token.
    5. Add another variable for FIREBASE_PROJECT and set it to your Firebase project's name.

Write .circleci/config.yml

I found this guide useful.

Example File

version: 2
jobs:
  build:
    docker:
      # Using latest can cause failures, but I hope it will help me keep up
      - image: circleci/node:latest
    steps:
      - checkout
      - run: npm install --prefix=./firebase-deploy firebase-tools
      - run: >
          ./firebase-deploy/node_modules/.bin/firebase deploy
          --project=$FIREBASE_PROJECT
          --token=$FIREBASE_DEPLOY_TOKEN

Locally validating your config

You can use CircleCI's local-ci. Note that this was tested on a dev Ubuntu server.

Install - official docs

snap install docker circleci
snap connect circleci:docker docker

Test your configuration file. Navigate to your project directory first.

circleci config validate
# or
circleci config validate <config file path>
Tags
ansible
Blog code last updated on 2024-02-18: 5ab386de2324c1884556552d0f043a42f2f726ab