#
# Publish GO HUGO GitLab Pages Site using Go Modules option
# Themes and template reference using GO Module system
#
stages:
- validate
- publish

test:
  image: registry.gitlab.com/pages/hugo/hugo_extended:latest
  stage: validate
  before_script:
  # Add Go Module dependencies
  - apk --no-cache add git
  - apk --no-cache add go
  script:
  # Test Site Generation Templates
  - hugo -D -E -F
  only:
  - dev

pages:
  image: registry.gitlab.com/pages/hugo/hugo_extended:latest
  stage: publish
  before_script:
  # Add Go Module dependencies
  - apk --no-cache add git
  - apk --no-cache add go
  script:
  # Generate Site from Repository Project
  - |
    echo "Add HUGO Configuration from CI-variables.    "
    echo "============================================="
    echo "baseURL: '$CI_PAGES_URL'" >> config/$CI_JOB_NAME/config.yml
    echo "title: '$CI_PROJECT_TITLE'" >> config/$CI_JOB_NAME/config.yml
  - hugo config --environment $CI_JOB_NAME
  - hugo -D -E -F --environment $CI_JOB_NAME
  artifacts:
    paths:
    - public
  only:
  - main

