Skip to content

Continuous integration

This is a bit of a mystery, but publishing a site is not as simple as just pushing files to the remote repo.

This involves CI

And as the repos are currently set up, the CI config expects to see a load of stuf about Mkdocs, so if you want to use flat html, you must set it up differently

Here’s a CI file for a flat HTML site:

https://gitlab.fabcloud.org/academany/fabacademy/2021/labs/barcelona/site/-/blob/master/.gitlab-ci.yml

# This file is a template, and might need editing before it works on your project.
# Full project: https://gitlab.com/pages/plain-html
pages:
  stage: deploy
  script:
    - mkdir .public
    - cp -r * .public
    - mv .public public
  artifacts:
    paths:
      - public
  only:
    - master

Here’s one for an MkDocs site:

image: python:3.8-slim

before_script:
  # install Git for the mkdocs revision plugin
  - time apt update && apt-get install -y git
  # Install mkdocs and theme
  - time pip install -r requirements.txt

test:
  stage: test
  script:
  - time mkdocs build --site-dir test
  artifacts:
    paths:
    - test
  except:
  - master

pages:
  stage: deploy
  variables:
    GIT_DEPTH: 1000
  script:
  - time mkdocs build --site-dir public
  artifacts:
    paths:
    - public
  only:
  - master

Note the reference to requirements.txt. That file also needs to exist in the same directory:

# Documentation static site generator
mkdocs >=1.1.2, ==1.1.*
mkdocs-git-revision-date-localized-plugin ~= 0.8.0

# Add your custom theme if not inside a theme_dir
# (https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes)
mkdocs-material ~= 6.2

Last update: March 19, 2021