Commit 39741d7f authored by Adrian DC's avatar Adrian DC
Browse files

ci(gitlab-ci): implement local pages serve in 'pages' job

Signed-off-by: default avatarAdrian DC <radian.dc@gmail.com>
parent 2ee62f77
Loading
Loading
Loading
Loading
Loading
+19 −30
Changes for .gitlab-ci.yml: 19 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -188,34 +188,6 @@ images:
  rules:
    - if: $CI_LOCAL

serve:
  stage: development
  image: local
  needs: []
  before_script:
    # Install dependencies
    - grep '^mkdocs[>=]\{1,\}.*\|^playwright' ./requirements/pages.txt | xargs -n1 -r pipx install
    - grep '^mkdocs-.*' ./requirements/pages.txt | xargs -r pipx inject mkdocs
    - grep '^git+.*mkdocs-exporter' ./requirements/pages.txt | xargs -r pipx inject mkdocs
    - playwright install chromium
  script:
    # Prepare documentation
    - |
      find ./config/* ./docs/* ./mkdocs.yml ./README.md -not -path ./docs/assets/stylesheets/variables.scss -type f | entr sh ./docs/prepare.sh &
      echo -n "${!}" >./docs/.serve.pid
      sleep 2
    # Generate documentation
    - |
      network_ip=$(hostname -I | cut -d' ' -f1)
      mkdocs serve --dev-addr "${network_ip}:8001" --clean --config-file ./mkdocs.yml --verbose || true
  after_script:
    # Cleanup documentation
    - cat ./docs/.serve.pid | xargs -r kill >/dev/null 2>&1 || true
    - sh ./docs/prepare.sh --clean
  rules:
    - if: $CI_LOCAL
  allow_failure: true

# =============================================================================
# Stage: prepare

@@ -675,11 +647,28 @@ pages:
        git fetch --tags --unshallow || true
      fi
    # Prepare documentation
    - sh ./docs/prepare.sh
    - |
      if [ ! -z "${CI_LOCAL:-}" ]; then
        find ./config/* ./docs/* ./mkdocs.yml ./README.md -not -path ./docs/assets/stylesheets/variables.scss -type f | entr -n sh ./docs/prepare.sh &
        echo -n "${!}" >./docs/.serve.pid
        sleep 2
      else
        sh ./docs/prepare.sh
      fi
    # Generate documentation
    - mkdocs build --clean --config-file ./mkdocs.yml --verbose
    - |
      if [ ! -z "${CI_LOCAL:-}" ]; then
        network_ip=$(hostname -I | cut -d' ' -f1)
        mkdocs serve --dev-addr "${network_ip}:8001" --clean --config-file ./mkdocs.yml --verbose || true
      else
        mkdocs build --clean --config-file ./mkdocs.yml --verbose
      fi
  after_script:
    # Cleanup documentation
    - |
      if [ -e ./docs/.serve.pid ]; then
        cat ./docs/.serve.pid | xargs -r kill >/dev/null 2>&1 || true
      fi
    - sh ./docs/prepare.sh --clean
  artifacts:
    expire_in: 1 hour