loading...

Firebase CI/CD with Cloud Source Repos + Cloud Build

amammay profile image Alex Mammay ・2 min read

firebase is a pretty sweet product, lets do a CI/CD pipeline with build triggers n'at, with newer version of firebase-tools we dont need to do the login:ci steps anymore and worry about managing creds in a KMS ring!

sample code is here at https://github.com/amammay/firebase_cloud_build_example

Push code to cloud source repo

  1. Create cloud source repo
    Cloud Source Repo

  2. Activate Cloud Shell and clone the sample code

    • git clone https://github.com/amammay/firebase_cloud_build_example.git
  3. Add a remote to the Cloud Source Repo. ( on the cloud source repo you will see a little guide for Pushing Code From a local local git repo)

  4. Push to Cloud Source repos git push --all google

Create build triggers

We will create 2 build triggers, one for changes to the firebase image, and the other for our source code

  1. Firebase Build trigger

    • firebase build
  2. Source Code Build trigger

    • source code trigger

Adjust service account

  1. Navigate to settings on cloud build and set the service account following items to enabled
    • Service Account

Run Firebase build trigger

Firebase Image Build

  1. We will run the firebase_build trigger first
    • A good run will then have firebase image listed as a build artifact ( you check this by navigating to GCR
    • GCR

Modify Source To have your project id

  1. Change the .firebaserc file to have your project as the default
{
  "projects": {
    "default": "samplefirebasecicd"
  }
}

Commit and push

  1. Watch the build 😬
  2. Celebrate Deployment 🚀🍺 Deployed

Discussion

markdown guide