Problem/Motivation
It would be helpful to be able to view rendered documentation in GitLab Pages when reviewing an MR.
Proposed resolution
The approach used by Member Platform: https://git.drupalcode.org/project/member/-/blob/1.0.x/.gitlab-ci.yml?re...
These are the two jobs in the template. We can update the rules so pages build with every MR. Leaving pages deploy job alone
pages:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_ROOT_NAMESPACE == "project"
changes:
- docs/**/*
- mkdocs.yml
needs: [Check Code]
image: python:3.12
script:
- pip install mkdocs-material
- mkdocs build --site-dir public
- echo "Pages accessible through ${CI_PAGES_URL}"
artifacts:
paths:
- public
pages:
stage: build
rules:
- *skip-pages-rule
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
when: never
- exists:
- mkdocs.yml
when: on_success
image: python:3.12
script:
- cd $CI_PROJECT_DIR && pwd
- pip install mkdocs-material
- pwd && ls -l logo* && ls -l docs/logo* || true
- |
if [[ -f logo.png ]]; then
# Do not copy the logo if the destination file already exists.
test -f docs/logo.png && echo "logo.png not copied to /docs because that file already exists." || cp -v logo.png docs/logo.png
fi
- echo "Executing mkdocs build --site-dir public $_MKDOCS_EXTRA"
- mkdocs build --site-dir public $_MKDOCS_EXTRA
- printf "$DIVIDER\n* The documentation will be published to the URL $CI_PAGES_URL in the 'pages:deploy' job.$DIVIDER\n"
artifacts:
paths:
- public
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
bluegeek9 commentedComment #4
jdleonardComment #6
jdleonardThis is mostly working.
I haven't quite figured out whether the pages-preview job is doing anything productive.
And I can't fully test this until it's merged, due to conditional logic about the context in which it is executed.
See https://git.drupalcode.org/issue/crm-3527319/-/jobs/6258897
Comment #7
bluegeek9 commentedComment #10
bluegeek9 commented