How to deploy only an affected nx service to GCP APP Engine

Viewed 486

Given that I have an NX application with multiple services, and I want to do continuous deployment of only affected service/s to App Engine, how can I point to a given service.yaml (or multiple) within the common cloudbuild.yaml for the project?
Each service in the monorepo has its own service.yaml as describe here
ex: My cloudbuild.yaml looks like:

steps:
- name: node
  entrypoint: npm
  args: ['install']
- name: node
  entrypoint: npm
  args: ['run', 'affected:build']
- name: 'gcr.io/cloud-builders/gcloud'
  args: ['app', 'deploy', 'dist/apps/express-app-1/service.yaml']
  timeout: '1600s'

In my code I am pointing to specific service which is hard-coded but I need it to depend on nx affected:build.

Is there a way to do that, and to achieve continuous deployment with nx build:affected and Cloud Build triggers?

1 Answers

From what I read so far there is no standardised or "official-the-NX" way of doing such things (yet).

Have a look here in this discussion. It was the best "answer" I found for myself, so far...

Maybe a quick and simple tip:

You could consume the output of print-affected in your CI in order to decide which apps need to be built / deployed.

npx nx print-affected --type=app --select=projects

Related