include:
  - project: 'sre/ci-building-blocks'
    file: '/gitlab-ci/node/kaniko.yml'

variables:
  INGRESS_HOSTNAME: manifest-$CI_COMMIT_REF_SLUG

build image:
  before_script:
    - "[ -z \"$APP_VERSION\" ] && export APP_VERSION=$CI_COMMIT_TAG"
    - "[ -z \"$APP_VERSION\" ] && export APP_VERSION=$(cat package.json | grep 'version' | cut -f 4 -d'\"')"
    - echo "Building version $APP_VERSION"
  extends: .build image

deploy helm chart:
  extends: .auto-deploy-helm-chart
  environment:
    name: $CI_COMMIT_REF_SLUG
    on_stop: tear down
    auto_stop_in: 1 week
    url: https://manifest-$CI_COMMIT_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
  after_script:
    - envsubst < .gitlab-ci/kubernetes-resources.yaml > tmp-k8s-resources.yaml
    - kubectl apply -f tmp-k8s-resources.yaml
