steps:
# Install top-level deps.
- name: 'gcr.io/learnjs-174218/release'
  entrypoint: 'yarn'
  id: 'yarn'
  args: ['install']

# Generate cloudbuild_generated.yml,
# which builds and tests all affected packages.
- name: 'gcr.io/learnjs-174218/release'
  entrypoint: 'yarn'
  id: 'generate-cloudbuild-for-packages'
  args: ['generate-cloudbuild-for-packages']
  waitFor: ['yarn']
  env:
  - 'COMMIT_SHA=$COMMIT_SHA'
  - 'BRANCH_NAME=$BRANCH_NAME'
  - 'BASE_BRANCH=$_BASE_BRANCH'
  - 'NIGHTLY=$_NIGHTLY'

# Run the generated cloudbuild file
- name: 'gcr.io/cloud-builders/gcloud'
  entrypoint: 'bash'
  id: 'run-cloudbuild'
  args: ['./scripts/run-build.sh']
  waitFor: ['generate-cloudbuild-for-packages']
  env: ['NIGHTLY=$_NIGHTLY']

# General settings.
timeout: 7200s
logsBucket: 'gs://tfjs-build-logs'
options:
  logStreamingOption: 'STREAM_ON'
  substitution_option: 'ALLOW_LOOSE'
