'GitLab Pages, docs generated with sphinx

I want to host static page generated with Sphinx on GitLab Pages. Built index.html file is in:

project/docs/build/html

How .gitlab-ci.yml should look like to deploy the page? I have something like that and it isn't working:

pages:
  stage: deploy
  script:
  - echo 'Nothing to do...'
 artifacts:
 paths:
 - docs/build/html
 only:
 - master


Solution 1:[1]

image: python:3.10-alpine

stages:
  - deploy

pages:
  tags:
    - sphinx
  stage: deploy
  script:
    - python3 -m pip install sphinx furo
    - sphinx-build -b html docs/source/ public/
  artifacts:
    paths:
      - public
  only:
    - main # 'master' was renamed to 'main' 

This is what my GitLab-ci.yml looks like. On a side note: You don't need a public-folder in your repository. GitLab itself will handle it. I installed furo as theme (make sure to change the conf.py accordingly) to make it look nicer.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 kerfuffle