steps:
  - name: "gcr.io/kaniko-project/executor:v1.23.2"
    id: "Build image and push"
    dir: "api"
    args:
      - "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA"
      - "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:latest"
      - "--dockerfile=Dockerfile"
      - "--context=."
      - "--build-arg=GIT_COMMIT=$SHORT_SHA"
      - "--snapshot-mode=time"

  - id: "Deploy to cloud run"
    name: "gcr.io/cloud-builders/gcloud"
    entrypoint: "bash"
    args:
      - "-c"
      - |
        gcloud run deploy $_SERVICE_NAME \
        --image=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA \
        --region=$_REGION --platform managed --allow-unauthenticated \
        --port=8000
options:
  substitutionOption: ALLOW_LOOSE

substitutions:
  _SERVICE_NAME: http-sms-api
  _REGION: us-east1
