I have an NX monorepo and would like to deploy only those apps which had a change since the last commit.
My cloudbuild.yaml looks like this:
steps:
- name: node:16-bullseye
entrypoint: yarn
args: ["install", "--frozen-lockfile"]
- name: node:16-bullseye
entrypoint: yarn
args: ["nx", "affected", "-t", "build"]
- name: "gcr.io/cloud-builders/gcloud"
entrypoint: bash
args: ["yarn", "nx", "affected", "-t", "deploy"]
The command yarn nx affected -t deploy
calls the deploy scripts of the apps with changes. These are defined as:
"deploy":{
"executor": "nx:run-commands",
"options": {
"commands": [
"cp ../../../apps/myapp/app.yaml .",
"gcloud app deploy"
],
"cwd": "dist/apps/myapp",
"parallel": false
}
},
So in essence they will copy the app.yaml
file and then run gcloud app deploy
from the directory the app is built in.
The problem is I can't get an environment in cloudbuild where both gcloud
and yarn
are available. The above example gives me the error bash: yarn: No such file or directory