Make OpenShift template to be part of .gitlab-ci.yml templates

Last week I started working on OpenShift review app for the purposes of demo: https://gitlab.com/gitlab-examples/review-apps-openshift/

We should probably think about generalizing this .gitlab-ci.yml file and include it in templates directory:

image: ayufan/openshift-cli

stages:
  - build
  - test
  - staging
  - production

variables:
  # Configure these variables in Secure Variables:
  # OPENSHIFT_SERVER: https://openshift.domain.com:8443
  # OPENSHIFT_TOKEN: my.openshift.token
  # OPENSHIFT_DOMAIN: routes.openshift.domain.com

before_script:
  - oc login "$OPENSHIFT_SERVER" --token="$OPENSHIFT_TOKEN" --insecure-skip-tls-verify
  - oc project "$CI_PROJECT_NAME"

build:
  stage: build
  before_script: []
  script:
    - echo build

test1:
  stage: test
  before_script: []
  script:
    - echo run tests

test2:
  stage: test
  before_script: []
  script:
    - echo run tests

.deploy: &deploy
  image: ayufan/openshift-cli
  script:
    - oc get services $APP || oc new-app . --name=$APP --strategy=docker
    - oc get routes $APP || oc expose service $APP --hostname=$APP_HOST
    - oc start-build $APP --from-dir=. --wait

production:
  <<: *deploy
  stage: production
  variables:
    APP: production
    APP_HOST: production.$OPENSHIFT_DOMAIN
  when: manual
  environment:
    name: production
    url: http://production.$OPENSHIFT_DOMAIN
  only:
    - master

staging:
  <<: *deploy
  stage: staging
  variables:
    APP: staging
    APP_HOST: staging.$OPENSHIFT_DOMAIN
  environment:
    name: staging
    url: http://staging.$OPENSHIFT_DOMAIN
  only:
    - master

review:
  <<: *deploy
  stage: staging
  variables:
    APP: review-$CI_BUILD_REF_NAME
    APP_HOST: $CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
  environment:
    name: review/$CI_BUILD_REF_NAME
    url: http://$CI_BUILD_REF_NAME.review.$OPENSHIFT_DOMAIN
  only:
    - branches
  except:
    - master

@markpundsack Could you help with looking what flow we should advice with that template?