stages:
  - build
  - test
  - deploy

variables:
  LANG: en_US.UTF-8

build site:
  stage: build
  script:
  - jekyll build
  artifacts:
    expire_in: 24 hrs
    paths:
    - _site

check duplicate uuids:
  stage: test
  allow_failure: true
  # requires "python-frontmatter==1.0.0"
  script:
    - /home/gitlab-runner/chaotikm-website-python-venv/bin/python3 check_uniqueness_of_uids.py

check for dead links:
  stage: test
  allow_failure: true
  # requires linkchecker
  script:
    - /home/gitlab-runner/chaotikm-website-python-venv/bin/linkchecker --no-status --check-extern --ignore-url '!chaotikum.org' --ignore-url '/blog/20(13|14|15|16|17|18)/.*' --no-warnings _site/ | sed -e "s|$CI_PROJECT_DIR||g"

check ical files:
  stage: test
  allow_failure: true
  # requires "requests==2.28.2" "icalendar==5.0.7"
  script:
    - /home/gitlab-runner/chaotikm-website-python-venv/bin/python3 check_ical.py

create media tickets:
  stage: test
  allow_failure: true
  # requires "requests==2.28.2" "xmltodict==0.13.0" "python-frontmatter==1.0.0"
  script:
    - /home/gitlab-runner/chaotikm-website-python-venv/bin/python3 media_ticket_generator.py

deploy:
  stage: deploy
  needs:
    - check duplicate uuids
    - check for dead links
    - build site
  dependencies:
    - build site
  only:
    - master
  cache:
    paths:
      - vendor/
  script:
    - rsync -6av --delete-after _site/ /var/www/html/
