image: timbru31/ruby-node:2.6-fermium

stages:
  - build
  - predeploy
  - generatepdf
  - afterdeploy

cache:
  paths:
  - vendor/

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  JEKYLL_ENV: production

before_script:
  - export LANG=en_US.UTF-8
  - export LANGUAGE=en_US:en
  - export LC_ALL=en_US.UTF-8

build_production:
    stage: build
    tags:
        - build
    script:
        - bundle install --path vendor
        - mkdir public
        - cp _config_production.yml _config.yml
        - cp _layouts/presentation_production.html _layouts/presentation.html
        - bundle exec jekyll build -d public
    variables:
        quarter: 23au
        course: cse493e
        source_path: public
    only:
        - UACCESS-23fa
    artifacts:
        paths:
            - public/

pre_deploy_production:
    stage: predeploy
    tags:
        - courseweb
    dependencies:
        - build_production
    script:
        - /www/utils/deploycourseweb.sh
    variables:
        quarter: 23au
        course: cse493e
        source_path: public
    only:
        - UACCESS-23fa

generate_pdf:
    stage: generatepdf
    tags:
        - build
    timeout: 3 hours 30 minutes
    dependencies:
        - build_production
    script:
        - bundle install --path vendor
        - script/deployslidepdf
    variables:
        quarter: 23au
        course: cse493e
        source_path: public
    only:
        - UACCESS-23fa
    artifacts:
        paths:
            - public/

after_deploy_production:
    stage: afterdeploy
    tags:
        - courseweb
    dependencies:
        - generate_pdf
    script:
        - /www/utils/deploycourseweb.sh
    variables:
        quarter: 23au
        course: cse493e
        source_path: public
    only:
        - UACCESS-23fa
