variables:
  EXPORT_DIR: "/var/www/html/pages"

stages:
  - test
  - deploy
  - cleanup
  
test-job:
  stage: test
  script:
    - echo "Testing files exist..."
    - test -f  public/index.html
    - test -f  public/main.js
    - test -f  public/settings.js
    - test -f  public/assets/css/style.css
    - test -f  public/assets/css/mobile.css
    - test -f  public/assets/images/header.jpg
    - test -f  public/assets/images/hft_logo.svg
    - test -f  public/home/index.html
    - echo "Test finished, all ok"
  only:
    - master
  
deploy-job:
  stage: deploy
  script:
    - if [ -d "$EXPORT_DIR/$CI_PROJECT_NAME" ]; then rm -r "$EXPORT_DIR/$CI_PROJECT_NAME"; fi
    - mkdir -p "$EXPORT_DIR/$CI_PROJECT_NAME"
    - cp -r public/* "$EXPORT_DIR/$CI_PROJECT_NAME"
  tags: 
    - docker
  only: 
    - master
  when: manual 

cleanup-job:
  stage: cleanup
  script:
    - if [ -d "$EXPORT_DIR/$CI_PROJECT_NAME" ]; then rm -r "$EXPORT_DIR/$CI_PROJECT_NAME"; fi
  tags: 
    - docker
  when: manual