Deploy the New Service

Let's deploy the newly created service.

What’s left to do is to test and deploy the service as part of our continuous deployment pipeline. We already have an example in .github/workflows/services-web.yml. Let’s look at the requirements.

Requirements

  1. Run the services-web workflow only when the web application code changes, not when underlying Firebase Cloud Functions change.
  2. For each Firebase Cloud Function, create an independent workflow and run it only when the specific service changes.

Updating workflow file

Due to the nature of how Firebase Cloud Functions are set up in sub-directories of services/web, the current services-web.yml workflow would be triggered for all changes to any of the Firebase Cloud Functions because we configured the trigger as follows:

on:
  push:
    paths:
      - "services/web/**"

The folks at GitHub thought of us when they designed the GitHub workflow syntax. Click Run and change the above to the following, including the negative pattern at the end:

on:
  push:
    paths:
      - "services/web/**"
      - "!services/web/firebase/functions/**"

To fully satisfy our first requirement, we also have to make sure the deploy step of the workflow deploys the Firebase Hosting and Firestore portions of the web application, but not the Firebase Cloud Functions, as we use separate workflows for these services. To achieve this, open services/web/firebase/package.json and update the deploy NPM script so it matches the following:

"scripts": {
  "deploy": "firebase deploy --only hosting,firestore"
}

Click Run again to save the changes.

Get hands-on with 1400+ tech skills courses.