Export in CI/CD
If documentation is stored in the same repository as code, you can generate the instruction file during the product build process. Use Gramax CLI for this.
Create a .gitlab-ci.yml file in the repository root (or update the existing one) and add an export stage with variables and steps.
stages— list of pipeline stages. For document export, we use theexportstage (you can rename it, but examples below assumeexport).variables— environment variables available in pipeline jobs.EXPORT_FILE_PATH— base output file path/name without extension.In examples:
EXPORT_FILE_PATH: artifacts/export→ output file is created asartifacts/export.[format].
Examples
stages: - export variables: EXPORT_FILE_PATH: artifacts/export export-docx: stage: export tags: - docker-linux-amd64 image: node:latest script: - npx gramax-cli export -f docx -o $EXPORT_FILE_PATH -y -t ./my-template.docx artifacts: paths: - artifacts
npx gramax-cli export -f docx -o $EXPORT_FILE_PATH -y -t ./my-template.docx — command for exporting documentation with Gramax CLI.
-f docx— export to DOCX.-o $EXPORT_FILE_PATH— path whereexport.docxwill be saved (in this example,export.docxis saved in theartifactsfolder).-y— automatically confirms actions without user prompts.-t— template path (optional).
stages: - export variables: EXPORT_FILE_PATH: artifacts/export export-pdf: stage: export tags: - docker-linux-amd64 image: node:latest script: - npx gramax-cli export -f beta-pdf -o $EXPORT_FILE_PATH -y --pdf-title --pdf-toc --pdf-number -t./template.css artifacts: paths: - artifacts
npx gramax-cli export -f beta-pdf -o $EXPORT_FILE_PATH -y --pdf-title --pdf-toc --pdf-number -t./template.css — command for exporting documentation with Gramax CLI.
-f beta-pdf— export to PDF.-o $EXPORT_FILE_PATH— path whereexport.pdfwill be saved (in this example,export.pdfis saved in theartifactsfolder).-y— automatically confirms actions without user prompts.-t— template path (optional).--pdf-title— add a title page (optional).--pdf-toc— add a table of contents (optional).--pdf-number— add heading numbering (optional).
Templates
Gramax CLI supports templates for both formats:
DOCX — template file
.docx(your styles, title page, headers/footers, etc.).PDF — CSS file (defines appearance when rendering PDF).
Single flag to attach a template — --template (-t):
gramax-cli export --template TEMPLATE
TEMPLATE can be:
A template file path (relative or absolute), for example:
./templates/my-template.docx.A template name from the current space, if specified without slashes, for example:
standard-report.
For example:
# Template name from workspace gramax-cli export --template standard-report # Template by path (DOCX) gramax-cli export -f docx --template ./templates/my-template.docx # Template by path (PDF) gramax-cli export -f beta-pdf --template ./templates/my-template.css