Commit a699c713 authored by Thibaud-Vdb's avatar Thibaud-Vdb
Browse files

Merge branch '433-new-job-marp' into 'latest'

Resolve "[New job] - Marp"

Closes #433

See merge request r2devops/hub!270
parents fb3403e7 b1b92ff6
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -150,6 +150,8 @@ LUA
Lua
lua
luacheck
Marp
marp
Markdownlint
markdownlint
md
@@ -183,6 +185,8 @@ opensource
os
OSS
OWASP
PDF
pdf
perlcritic
php
PHPCS
@@ -386,3 +390,4 @@ Hotjar
Hotjar's
pseudonymized
de
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ This job analyzes a remote website (or a local web service) and gives you a repo

* Job name: `lighthouse`
* Docker image:
[`justinribeiro/lighthouse`](https://hub.docker.com/r/justinribeiro/lighthouse)
[`zenika/alpine-chrome:89-with-node`](https://hub.docker.com/r/zenika/alpine-chrome){:target="_blank"}
* Default stage: `dynamic_tests`
* When: `always`

jobs/marp/README.md

0 → 100644
+63 −0
Original line number Diff line number Diff line
## Objective

Build HTML slides form Markdown using [Marp](https://marp.app/){:target="_blank"}.


## How to use it

1. Prepare your project with markdown files (.md files) under a default `slides` root directory (it could be another folder, but the name must be change in the `$MARP_INPUT_PATH` variable).
    
    !!! warning
        if the directory specified doesn't exists or is empty, the job will fails.


2. Add this job URL inside the `include` list of your `.gitlab-ci.yml` file (see the [quick setup](/use-the-hub/#quick-setup)). You can specify [a fixed version](#changelog) instead of `latest`.
    ```yaml
      - remote: 'https://jobs.r2devops.io/latest/marp.yml'
    ```
3. If you need to customize the job (stage, variables, ...) 👉 check the [jobs
   customization](/use-the-hub/#jobs-customization)

4. Well done, your job is ready to work ! 😀
    


## Job details

* Job name: `marp`
* Docker image:
[`zenika/alpine-chrome:89-with-node-14`](https://hub.docker.com/r/zenika/alpine-chrome){:target="_blank"}
* Default stage: `build`
* When: `always`


### Variables

!!! note
    `MARP_INPUT_PATH` is relative and start from the root of your
    repository.  
    `MARP_OUTPUT_PATH` depends on the environment variable `CI_PROJECT_DIR`


| Name | Description | Default |
| ---- | ----------- | ------- |
| `MARP_INPUT_PATH` | Input directory path | `slides/` |
| `MARP_OUTPUT_PATH` | Output directory path | `website_build/` |
| `GENERATE_PDF` | Should generate pdf files | `true` |
| `MARP_ADDITIONNAL_OPTIONS` | Other [options](https://github.com/marp-team/marp-cli#by-cli-option){:target="_blank"} you may want to use with Marp | ` ` |
| `NPM_INSTALL_DIR` | Custom installation directory for `npm` | `.npm-global/` |
| `CHROME_PATH` | Custom path for chromium (needed to avoid permission error on generating pdf) | `/usr/bin/chromium-browser` |


### Artifacts

When the job is successful, the build of your documentation is available as artifact.

!!! warning
    It's also [exposed as](https://docs.gitlab.com/ee/ci/yaml/#artifactsexpose_as){:target="_blank"}
    `marp build` in merge requests.
    Exposition of artifact currently works only if you keep `MARP_OUTPUT_PATH`
    default value because of [this issue from
    Gitlab](https://gitlab.com/gitlab-org/gitlab/-/issues/37129){:target="_blank"}.
    As soon as the issue will be fixed, exposed artifacts will be available
    with any output location.

jobs/marp/job.yml

0 → 100644
+13 −0
Original line number Diff line number Diff line
name: marp
description: A ready-to-use Marp job to build HTML and PDF slides using Markdown. 
default_stage: build
icon: 📃
maintainer: GridexX
license: MIT
images:
 "zenika/alpine-chrome": "89-with-node-14"
tools:
  "marp-cli": "1.4.1"
labels:
  - GitLab
  - Documentation
 No newline at end of file

jobs/marp/marp.yml

0 → 100644
+40 −0
Original line number Diff line number Diff line
#Job from R2Devops hub --> r2devops.io

stages:
  - build

marp:
  image:
    name: zenika/alpine-chrome:89-with-node-14
    entrypoint: [""]
  stage: build
  variables:
    MARP_OUTPUT_PATH: 'website_build/'
    MARP_INPUT_PATH: 'slides/'
    GENERATE_PDF: 'true'
    MARP_ADDITIONNAL_OPTIONS: ' '

    #Custom installation directory for npm in order to use marp command
    NPM_INSTALL_DIR: ".npm-global"
    #Custom path is needed to avoid permission error on generating pdf
    CHROME_PATH: "/usr/bin/chromium-browser"
  script:
    - mkdir ${CI_PROJECT_DIR}/${NPM_INSTALL_DIR}
    - npm config set prefix '${CI_PROJECT_DIR}/${NPM_INSTALL_DIR}'

    - export PATH=${CI_PROJECT_DIR}/${NPM_INSTALL_DIR}/bin:$PATH

    - npm install -g @marp-team/marp-cli@1.4.1 

    - marp ${MARP_ADDITIONNAL_OPTIONS} -I $MARP_INPUT_PATH -o ${CI_PROJECT_DIR}/${MARP_OUTPUT_PATH}
    - if [ $GENERATE_PDF == "true" ]; then
    -   marp ${MARP_ADDITIONNAL_OPTIONS} --pdf -I $MARP_INPUT_PATH -o ${CI_PROJECT_DIR}/${MARP_OUTPUT_PATH}
    - fi
  artifacts:
    when: always
    expose_as: "marp build"
    paths:
      - "$MARP_OUTPUT_PATH"
      # Below path is a workaround to provide artifact exposition in MR if
      # default output value is used. See https://r2devops.io/jobs/build/mkdocs/#artifacts
      - "website_build/"
Loading