# Copyright 2022 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Execute workflow debian_worker.wf.json to build a new Debian worker.
# Tested with Debian 10 and Debian 11.
#
# To run the Cloud Build workflow, execute the following from the root
# directory:
# gcloud builds submit --config=debian_worker_cloudbuild.yaml .

timeout: 4500s

substitutions:
  _BUILDER_PROJECT: 'compute-image-import-builder'
  _GCS_PATH: 'gs://compute-image-import-builder'
  _IMAGE_PROJECT: 'compute-image-import'
  _DAISY_WORKFLOW: '/workspace/daisy_workflows/image_build/debian/debian_worker.wf.json'
  _DAISY_DOCKER_TAG: 'latest'

steps:
# Build Debian 11 worker.
- id: 'build-debian-11-worker'
  name: 'gcr.io/compute-image-tools/daisy:${_DAISY_DOCKER_TAG}'
  args: [
        '-gcs_path=${_GCS_PATH}',
        '-project=${_BUILDER_PROJECT}',
        '-var:commit_sha=$COMMIT_SHA',
        '-var:family_tag=debian-11-worker',
        '-var:image_prefix=debian-11-worker',
        '-var:image_project=${_IMAGE_PROJECT}',
        '-var:source_image=projects/debian-cloud/global/images/family/debian-11',
        '${_DAISY_WORKFLOW}'
        ]
