# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
#

stages:
  - preprocessor-test
  - build
  - deploy

# always test the preprocessor and pandoc build with unit tests
testing:
  stage: preprocessor-test
  allow_failure: false
  image: 
    name: alpine:latest
  script:
    - apk add --no-cache --upgrade bash
    - RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
    # run shell script with testss
    - $RESEARCH_ROOT/bin/run-tests.sh
  artifacts:
    paths:
      - testing/*.log

# build static webpage
build-static:
  stage: build
  allow_failure: false
  image: 
    name: eltenedor/ubuntu-pandoc:latest
  script:
    - RESEARCH_ROOT=`pwd`; export RESEARCH_ROOT;
    # build static webpage
    - $RESEARCH_ROOT/bin/build_static.sh
  artifacts:
    paths:
      - static

# deploy static webpage to web-server via GitLab pages
pages:
  stage: deploy
  script:
    - mkdir .public
    - cp -r static/public/*.html .public
    - cp -r img .public/.
    - cp -r css .public/.
    - mv .public public
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_BRANCH == master