stages:
  - deploy

variables:
  OPENSHIFT_SERVER: https://okd-dev.hbp.eu
  BUILD_ENV: int-build

deploy-artifacts:
  stage: deploy
  before_script:
    - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN"
  script:
    # create job description file
    - chmod a+x create_job.sh
    - ./create_job.sh $BUILD_ENV
    - cat simplejob.yml
    # select the project in openshift
    - oc project jupyterhub-int
    # delete the job (if exist)
    - oc delete job simplejob || true
    # start the deploy job
    - oc create -f simplejob.yml
    # wait for job to finish https://stackoverflow.com/questions/5073453wait-for-kubernetes-job-to-complete-on-either-failure-success-using-command-line
    - oc get job/simplejob -o=jsonpath='{.status}' -w 
    - oc get job/simplejob -o=jsonpath='{.status.conditions[*].type}' | grep -i -E 'failed|complete' || echo 'Failed' 
  tags:
    - shell-runner



