
review:
  extends: .deploy
  environment:
    name: development
    on_stop: stop_review
  variables:
    LABEL: review-mr${CI_MERGE_REQUEST_IID}
    APPLICATION: application-review-mr${CI_MERGE_REQUEST_IID}
    DATABASE_HOST: {{ cookiecutter.database|lower }}-review-mr${CI_MERGE_REQUEST_IID}
{%- if cookiecutter.environment_strategy == 'dedicated' %}
    SOURCE: {{ cookiecutter.cloud_project }}-development
    TARGET: {{ cookiecutter.cloud_project }}-development
{%- endif %}
  only:
  - merge_requests

stop_review:
  extends: review
  environment:
    action: stop
  variables:
    GIT_STRATEGY: none
  when: manual
  before_script:
  script:
  - oc delete all,configmap,pvc,secret -n ${TARGET} -l app=${LABEL}

integration:
  extends: .deploy
  environment:
    name: integration
{%- if cookiecutter.environment_strategy == 'dedicated' %}
  variables:
    SOURCE: {{ cookiecutter.cloud_project }}-development
    TARGET: {{ cookiecutter.cloud_project }}-integration
{%- endif %}
  only:
  - master

production:
  extends: .deploy
  environment:
    name: production
{%- if cookiecutter.environment_strategy == 'dedicated' %}
  variables:
    SOURCE: {{ cookiecutter.cloud_project }}-integration
    TARGET: {{ cookiecutter.cloud_project }}-production
{%- endif %}
  only:
  - tags


review:
  extends: .deploy
  environment:
    name: development
    on_stop: stop_review
    auto_stop_in: 1 day
  variables:
    LABEL: review-mr${CI_MERGE_REQUEST_IID}
    APPLICATION: application-review-mr${CI_MERGE_REQUEST_IID}
    DATABASE_HOST: {{ cookiecutter.database|lower }}-review-mr${CI_MERGE_REQUEST_IID}
{%- if cookiecutter.environment_strategy == 'dedicated' %}
    SOURCE: {{ cookiecutter.cloud_project }}-development
    TARGET: {{ cookiecutter.cloud_project }}-development
{%- endif %}
  only:
  - merge_requests

stop_review:
  extends: review
  environment:
    action: stop
  variables:
    GIT_STRATEGY: none
  when: manual
  before_script:
  script:
  - oc delete all,configmap,pvc,secret -n ${TARGET} -l app=${LABEL}

integration:
  extends: .deploy
  environment:
    name: integration
{%- if cookiecutter.environment_strategy == 'dedicated' %}
  variables:
    SOURCE: {{ cookiecutter.cloud_project }}-development
    TARGET: {{ cookiecutter.cloud_project }}-integration
{%- endif %}
  only:
  - master

production:
  extends: .deploy
  environment:
    name: production
{%- if cookiecutter.environment_strategy == 'dedicated' %}
  variables:
    SOURCE: {{ cookiecutter.cloud_project }}-integration
    TARGET: {{ cookiecutter.cloud_project }}-production
{%- endif %}
  only:
  - tags

Make review apps die automatically after a day
Make review apps die automatically after a day

We build our demos on a daily basis. Hence, at least one new MR
will be opened each day, which corresponds to another review app
being deployed. The old one would *not* disappear automatically.
We could add "deleting of all review apps" to the field test
script, but the `auto-stop` GitLab feature seems just good enough,
so that we can spare the effort.
