CircleCI: Continuous Delivery for Firebase
Posted by Kyle Pericak in development
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
firebase login:ci
Add token as CircleCI env var
- Log into CircleCI
- Choose your GitHub project
- Use the Hello World build template
- Assign that token as
$FIREBASE_DEPLOY_TOKEN
in the project's environment variable settings.- Navigate to your project in CircleCI
- Click the gear on the top-right to open this project's settings
- Open environment variables page
- Add Variable. Name:
FIREBASE_DEPLOY_TOKEN
, value is your token. - 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>