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

Issue fork crm-3527319

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jdleonard created an issue. See original summary.

bluegeek9’s picture

Issue summary: View changes

jdleonard’s picture

Assigned: Unassigned » jdleonard

bluegeek9 changed the visibility of the branch 1.0.x to hidden.

jdleonard’s picture

Assigned: jdleonard » Unassigned
Status: Active » Needs review

This 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

bluegeek9’s picture

Assigned: Unassigned » bluegeek9
Status: Needs review » Active

  • bluegeek9 committed 3ebae39b on 1.0.x
    task: #3527319 Ability to preview GitLab Pages in CI
    
bluegeek9’s picture

Assigned: bluegeek9 » Unassigned
Status: Active » Fixed
//www.flaticon.com/free-icons/thank-you Thank you for your contribution! Your continued support makes this project sustainable.
There are multiple ways to show appreciation for the work contributed to this project including:
  • Triage issues and adding more context to existing issues.
  • Flagging CRM as a favorite on the project page to help others discover it and show your support.
  • Review the Developer Docs for accuracy and clarity.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.