Deploy to Firebase Hosting from GitHub

Pavan
4 min readMay 24, 2017

--

Follow the steps to deploy to Firebase hosting from GitHub via Travis CI

This is the detailed version of https://www.youtube.com/watch?v=QLVzozWDYAs.

We will the setup the below flow.

Apps are developed on local developer machines
Pushed to GitHub
Travis CI deploys the app to Firebase Hosting from GitHub

I assume that you have:

Basic understanding of Firebase
Installed node
Installed firebase tools
Installed Git

Lets Start!

Setting up GitHub

Login to GitHub
Create a new repository

Open command prompt, Navigate to your working directory

cd yourdirectory

clone the repository to the directory

git clone repositoryname.git

Setting up Firebase

Login to Firebase, Go to Firebase console

Add a new project

come back to the command line

Login to your account

firebase login

Initialise firebase app

firebase init

choose a project

Type yes to Install the dependencies

Continue…

To integrate with Travis CI, we would need Firebase token.

Type in command line

firebase login:ci

This will open up a browser to sign in once more

Copy the token, we will need this for Travis CI

Create .travis.yml file in the root of the project, and paste the following in file

Make sure you replace projectId with the actual projectId, which can be found in the firebase console

projectId can be found in Firebase console

Setting Up Travis CI

Login to travis-ci.org

Click on signin with GitHub

Click on “+” sign next to my repositories

All the GitHub projects will be listed.
If not visible click on “Sync Account”

Next to the Repository name click on “x” button to flip the switch

Now click the gear icon before the repository.

Under “Environment Variables” add
“FIREBASE_TOKEN” and the previously generated token via firebase login:ci
This will help Travis CI to deploy to Firebase Hosting

Come back to command line, and do a git push to the GitHub repo

git add .

git commit -m “commit message”

git push origin master

After these three the code gets pushed to GitHub, from there Travis CI starts the process, Ideally you would run the tests in Travis CI, for simplicity of the setup , there are no running tests.

Thats it !! The app is deployed to Firebase Hosting.

--

--