# Copyright 2023 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

steps:
  # Build the container image
  - name: "gcr.io/cloud-builders/docker"
    args:
      - "build"
      - "-t"
      - "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
      - "-f"
      - "godev/cmd/telemetrygodev/Dockerfile"
      - "."
  # Push the container image to Container Registry
  - name: "gcr.io/cloud-builders/docker"
    args:
      - "push"
      - "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
  - name: golang
    args:
      - "go"
      - "run"
      - "golang.org/x/website/cmd/locktrigger@latest"
      - "--project=$PROJECT_ID"
      - "--build=$BUILD_ID"
      - "--repo=https://go.googlesource.com/telemetry"
  # Deploy container image to Cloud Run
  - name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
    entrypoint: gcloud
    args:
      - "run"
      - "deploy"
      - "$_ENV-telemetry"
      - "--image"
      - "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
      - "--region"
      - "us-central1"
      - "--service-account"
      - "$_RUN_SERVICE_ACCOUNT"
      - "--set-env-vars"
      - "GO_TELEMETRY_PROJECT_ID=$PROJECT_ID,GO_TELEMETRY_ENV=$_ENV"
images:
  - "gcr.io/$PROJECT_ID/telemetrygodev:$COMMIT_SHA"
