steps:
  - name: gcr.io/k8s-skaffold/pack
    env:
      - GOOGLE_ENTRYPOINT=$_ENTRYPOINT
    args:
      - build
      - >-
        $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
      - '--builder=gcr.io/buildpacks/builder:google-22'
      - '--network=cloudbuild'
      - '--path=.'
      - '--env=GOOGLE_ENTRYPOINT'
    id: Buildpack
    entrypoint: pack

  - name: gcr.io/cloud-builders/docker
    args:
      - push
      - >-
        $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
    id: Push

  - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
    args:
      - run
      - services
      - update
      - $_SERVICE_NAME
      - '--platform=managed'
      - >-
        --image=$_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA
      - >-
        --labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID
      - '--region=$_DEPLOY_REGION'
      - '--quiet'
    id: Deploy
    entrypoint: gcloud

images:
  - >-
    $_AR_HOSTNAME/$_AR_PROJECT_ID/$_AR_REPOSITORY/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA

options:
  substitutionOption: ALLOW_LOOSE
  logging: CLOUD_LOGGING_ONLY

substitutions:
  _SERVICE_NAME: movie-posters
  _ENTRYPOINT: /lib/index.js
  _DEPLOY_REGION: europe-west1
  _AR_HOSTNAME: europe-west1-docker.pkg.dev
  _AR_REPOSITORY: cloud-run-source-deploy
  _TRIGGER_ID: ab011af3-225f-4c07-8ca9-aded41b4cb5a
  _AR_PROJECT_ID: firmware-hq
  _PLATFORM: managed

tags:
  - gcp-cloud-build-deploy-cloud-run
  - gcp-cloud-build-deploy-cloud-run-managed
  - movie-posters
