stages:
  - build
  - push

build:
  stage: build
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  only:
    - master
  script:
    - /kaniko/executor
      --cache=true
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "dcr.faked.org/chitui:${CI_COMMIT_SHORT_SHA}"

push_latest:
  stage: push
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  only:
    - master
  script:
    - crane copy dcr.faked.org/chitui:${CI_COMMIT_SHORT_SHA} dcr.faked.org/chitui:latest

push_tag:
  stage: push
  image:
    name: gcr.io/go-containerregistry/crane:debug
    entrypoint: [""]
  only:
    - tags
  script:
    - crane copy dcr.faked.org/chitui:${CI_COMMIT_SHORT_SHA} dcr.faked.org/chitui:${CI_COMMIT_TAG}
