firebasegithubworkflowfirebase-hosting

how to automatically deploy to firebase on commit to main branch?


The Main part

I am trying to create a comfortable workflow for myself. I just want to know is there any way to automate deploys from GitHub Repo to Firebase hosting when I commit changes in the repo's main branch at my desktop and push origin to GitHub?

...possibly using "GitHub actions"...

Context and what I've tried

As on 15-Jan-2022 there are two ways I found of deploying website files to firebase hosting.

  1. The de facto firebase cli way, where you use firebase deploy command to push files to firebase hosting.
  2. The automated way using github actions, where the site is deployed automatically every time a pull request is created.

The first one is tedious, the second one is not my cup of cake. Especially because the workflow I want to setup is not too much git oriented, I don't use "pull requests" as far as I understand. I just commit changes directly in the main branch.

(That is so because, I am not a programmer, I just trying to create a blogging site using the Firebase hosting + GitHub repo)

I also referred https://medium.com/firebase-developers/the-comprehensive-guide-to-github-actions-and-firebase-hosting-818502d86c31


Solution

  • Use Deploy to live & preview channels via GitHub pull requests. It will work if you use pull requests to review changes or if you push commits directly to the primary branch.

    I would recommend that you use pull requests though. It's a great flow to double check your changes and with the Firebase action it will deploy a temporary preview of the the changes so you can validate everything looks correct.