Deploy Apps And Functions To Firebase From A Mono Repo With GitHub Actions

How to deploy applications and functions from a mono repo with GitHub Actions to Firebase Hosting and Functions

David Dal Busco
4 min readMar 23, 2020

--

Photo by 张 嘴 on Unsplash

I share one trick a day until the end of the COVID-19 quarantine in Switzerland, April 19th 2020. Twenty-seven days left until hopefully better days.

I am a big fan of a blog post published by Julien Renaux a couple of months ago in which he displays how to deploy an application using GitHub Actions to Firebase Hosting.

The article is super comprehensive and I even already have published a following post about it once before 🤣. Nevertheless I think that this challenge is the perfect excuse to publish again another follow-up 😉.

Mono Repo

Our open source project DeckDeckGo contains many Progressive Web Apps and Cloud Functions, for which, obviously, I did set up GitHub actions as Julien displayed.

In this blog post I share the enhancement I had to implement in order to make the integration supports a mono repo.

To Firebase Hosting

Let’s say that one of your application is available in a sub-folder of our repo called docs . Basically, everything you have to do in addition to the original post is to prefix all steps of the Action with your sub-directory, respectively with docs .

Concretely, if for example we would like to trigger the action when a merge happens in the master branch, but, only if a modifications impacts our specific app, we specify a path to the Action on listener.

Listen to push to master for the all repo:

on:
push:
branches:
- master

Listen to push to master only if sub-folder is affected:

on:
push:
branches:
- master
paths:
- 'docs/**'

Because the Git checkout of our pipeline happens on the root level of our repo, when it goes to installing dependencies or running a build, we do have to observe our sub-folder too. For such purpose, GitHub Action provides a handy option working-directory for the npm steps.

--

--

David Dal Busco

Freelancer by day | Creator of Juno.build by night