# author: Ole Schuett

substitutions:
  _IMAGE_NAME: "us-central1-docker.pkg.dev/${PROJECT_ID}/misc/img_cp2k_precommit"

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ["build", "--build-arg", "REVISION=${SHORT_SHA}", "-t", "${_IMAGE_NAME}:${SHORT_SHA}", "./tools/precommit/"]

- name: 'gcr.io/cloud-builders/docker'
  args: ["push", "${_IMAGE_NAME}:${SHORT_SHA}"]

- name: 'gcr.io/cloud-builders/docker'
  args: ["tag", "${_IMAGE_NAME}:${SHORT_SHA}", "${_IMAGE_NAME}:latest"]

- name: 'gcr.io/cloud-builders/docker'
  args: ["push", "${_IMAGE_NAME}:latest"]

- name: "gcr.io/cloud-builders/gcloud"
  args:
   - "run"
   - "deploy"
   - "cp2k-precommit"
   - "--platform=managed"
   - "--region=us-central1"
   - "--image=${_IMAGE_NAME}:${SHORT_SHA}"

#EOF
