Skip to content

CI/CD GitLab Examples @ Coding:

Automating deployment or checks could save you time. Below you will find GitLab CI/CD yml file examples to help you.

MKDocs:

Requirements:

  1. Have a mkdocs.yml file and properly configured. MkDocs Docs
  2. Have a docs directory with .md files showcasing the documentation.

CI/CD Script Example:

image: python:3.9

pages:
    stage: deploy
    script:
        - pip install mkdocs
        - mkdocs build
        - mv site/ public/
    artifacts:
        paths:
            - public
    only:
        - main

MkDocs-Material

To use MkDocs-Material. (A fork of MkDocs). Use the CI/CD script below. Please note this is a fork of MkDocs. We recommend it instead of using the official MkDocs Library (Static Website Generator). Before deployment, please ensure you have passed all the requirements listed in the normal MkDocs Guide. MkDocs Material's Docs and an Example Config File is linked below:

CI/CD Script Example:

image: python:3.9

pages:
    stage: deploy
    script:
        - pip install mkdocs-material 
        - mkdocs build
        - mv site/ public/
    artifacts:
        paths:
            - public
    only:
        - main

HTML Page:

Requirements:

  • Have a functional .html file named "html".

CI/CD Script Example:

image: alpine:latest

pages:
    stage: deploy
    script:
        - mkdir .public
        - cp -r * .public
        - mv .public public
    artifacts:
        paths:
            - public
    only:
        - main

GitBook

Requirements:

  • Have a README.md file.

CI/CD Script Example:

image: node:10
cache:
    paths:
        - node_modules/ 
before_script:
    - npm install gitbook-cli -g 
    - gitbook fetch 3.2.3 n
    - gitbook install 
test:
    stage: test
    script:
        - gitbook build . public 
    rules:
        - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
pages:
    stage: deploy
    script:
        - gitbook build . public 
    artifacts:
        paths:
            - public
        expire_in: 1 week
    rules:
        - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH