stages:
  - purge
  - build
  - rf-test
  - push-results

docker-push:
  image: docker
  services:
    - docker:dind
  stage: purge
  tags: ['docker']
  only:
    - testing
  script:
    - docker stop front
    - docker rm front
  allow_failure: true

docker-build:
  image: docker
  services:
    - docker:dind
  stage: build
  tags: ['docker']
  only:
    - testing
  script:
    - printf "REACT_APP_URL=%s\n" "$REACT_APP_URL" > .env
    - docker build -t overflow2019/frontend:test .
    - docker run --name front -p 8080:80 -d overflow2019/frontend:test

rf-test:
  image: gitlab.labranet.jamk.fi:4567/wimma-lab-2019/mysticons/devsecops/robot
  stage: rf-test
  tags: ['docker']
  only:
    - testing
  script:
    - export ROBOT_TESTS=./tests
    - export OUTPUT_DIR=./results
    - run.sh
  artifacts:
    when: always
    untracked: true
    expire_in: 24h

push-results:
  stage: push-results
  tags: ['shell']
  only:
    - testing
  when: always
  script:
    - docker cp ./results front:/usr/share/nginx/html
