Documentation Generation

Creating Documentation Pages

< >

4. Deploying Documentation to GitLab Pages

Once your documentation is ready, you can set up GitLab CI/CD to automatically build and deploy it to GitLab Pages.

Practical Exercise

  1. Create a .gitlab-ci.yml File:

    • In your project root, create a .gitlab-ci.yml file with the following content:
      image: python:3.8
      
      pages:
        stage: deploy
        script:
          - pip install mkdocs
          - mkdocs build -d public
        artifacts:
          paths:
            - public
      
  2. Push Changes to GitLab:

    • Commit your changes and push to your GitLab repository:
      git add .
      git commit -m "Set up MkDocs and GitLab CI/CD"
      git push origin main
      
  3. Access GitLab Pages:

    • After the pipeline runs successfully, navigate to Settings > Pages in your GitLab repository to find the URL of your deployed documentation.