Skip to content

Example repository demonstrating the markdown-to-pdf-action with comprehensive workflow examples, sample documents, and custom themes

Notifications You must be signed in to change notification settings

MystaMax/markdown-to-pdf-action-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

Markdown to PDF Action - Examples

GitHub Action Examples

This repository demonstrates the markdown-to-pdf-action with real-world examples, workflow configurations, and custom themes. Fork this repository to get started quickly or use it as a reference for your own implementation.

πŸš€ Quick Start

1. Fork This Repository

Click the "Fork" button at the top of this page to create your own copy.

2. Enable GitHub Actions

Go to the "Actions" tab in your fork and enable workflows.

3. Trigger a Workflow

Choose any workflow from the examples:

  • Go to Actions tab
  • Select a workflow from the left sidebar
  • Click Run workflow
  • Download the generated PDFs from the workflow artifacts

πŸ“š What's Included

Workflow Examples

Located in .github/workflows/, these demonstrate different use cases:

Workflow Description Key Features
basic.yml Simple single-file conversion Default settings, minimal configuration
advanced.yml Full-featured example Custom CSS, metadata, multiple files
multi-format.yml Different paper sizes and themes A4/Letter, Portrait/Landscape, themes
conditional.yml Process only changed files Efficient CI/CD integration
scheduled.yml Weekly documentation export Cron scheduling, organized artifacts
pr-preview.yml Preview docs in pull requests PR integration, automatic comments

Sample Documents

Located in docs/ and examples/, these showcase various Markdown features:

  • Basic Markdown: Headers, lists, links, emphasis
  • Code Blocks: Syntax highlighting across languages
  • Tables: Professional table formatting
  • Images: Embedded images and diagrams
  • Task Lists: Interactive checkboxes
  • Emojis: GitHub-style emoji rendering
  • Table of Contents: Auto-generated navigation

Custom Themes

Located in assets/css/, ready-to-use professional themes:

  • professional-theme.css: Business documents with modern styling
  • technical-theme.css: API docs and technical specifications
  • minimal-theme.css: Clean, distraction-free reading
  • executive-theme.css: Executive summaries and reports

πŸ“– Examples by Use Case

Basic Usage

Convert a single Markdown file to PDF:

- name: Convert README to PDF
  uses: MystaMax/markdown-to-pdf@v1
  with:
      include-patterns: 'README.md'
      artifact-name: 'readme-pdf'

Try it: See .github/workflows/basic.yml

Custom Styling

Apply custom CSS for branded PDFs:

- name: Convert with custom theme
  uses: MystaMax/markdown-to-pdf@v1
  with:
      include-patterns: 'docs/**/*.md'
      css-file: 'assets/css/professional-theme.css'
      paper-size: 'A4'
      orientation: 'portrait'

Try it: See .github/workflows/advanced.yml

Multiple Formats

Generate different PDF formats from the same content:

strategy:
    matrix:
        include:
            - paper: 'A4'
              orientation: 'portrait'
              theme: 'professional'
            - paper: 'Letter'
              orientation: 'landscape'
              theme: 'technical'

Try it: See .github/workflows/multi-format.yml

CI/CD Integration

Process only changed files on pull requests:

- name: Get changed Markdown files
  uses: tj-actions/changed-files@v44
  with:
      files: '**/*.md'

- name: Convert changed files
  if: steps.changed-files.outputs.any_changed == 'true'
  uses: MystaMax/markdown-to-pdf@v1
  with:
      include-patterns: ${{ steps.changed-files.outputs.all_changed_files }}

Try it: See .github/workflows/conditional.yml

Scheduled Reports

Automate weekly documentation exports:

on:
    schedule:
        - cron: '0 9 * * 1'  # Every Monday at 9 AM

jobs:
    weekly-export:
        # ... generate PDFs with date-stamped artifacts

Try it: See .github/workflows/scheduled.yml

🎨 Customization Guide

Using Custom CSS

  1. Create a CSS file in assets/css/
  2. Reference it in your workflow:
with:
    css-file: 'assets/css/my-custom-theme.css'
  1. See assets/css/README.md for CSS examples and tips

Front Matter Metadata

Add metadata to individual Markdown files:

---
title: "My Document Title"
author: "Your Name"
subject: "Document Category"
date: "2024-01-15"
---

# Your Content Here

File Organization

Organize PDFs in artifacts:

with:
    artifact-path-mode: 'preserve'  # Keep folder structure
    artifact-subdir: 'reports/2024'  # Organize by date

πŸ§ͺ Testing Locally

While the action runs in GitHub Actions, you can test your Markdown rendering:

  1. Preview Markdown: Use VS Code, GitHub, or any Markdown viewer
  2. Validate CSS: Use browser dev tools to test styles
  3. Check Images: Ensure all image paths are relative and files exist

πŸ“ Repository Structure

markdown-to-pdf-action-examples/
β”œβ”€β”€ README.md                          # This file
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ basic.yml                  # Simple example
β”‚       β”œβ”€β”€ advanced.yml               # Full-featured example
β”‚       β”œβ”€β”€ multi-format.yml           # Multiple outputs
β”‚       β”œβ”€β”€ conditional.yml            # Changed files only
β”‚       β”œβ”€β”€ scheduled.yml              # Weekly automation
β”‚       └── pr-preview.yml             # PR integration
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ getting-started.md             # Beginner's guide
β”‚   β”œβ”€β”€ advanced-features.md           # Advanced usage
β”‚   β”œβ”€β”€ api-reference.md               # API documentation style
β”‚   β”œβ”€β”€ troubleshooting.md             # Common issues
β”‚   └── images/
β”‚       └── architecture-diagram.png    # Sample image
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ basic/
β”‚   β”‚   β”œβ”€β”€ README.md                  # Basic example overview
β”‚   β”‚   └── simple-document.md         # Minimal Markdown
β”‚   β”œβ”€β”€ code-heavy/
β”‚   β”‚   β”œβ”€β”€ README.md                  # Code-heavy docs overview
β”‚   β”‚   └── api-guide.md               # With code blocks
β”‚   β”œβ”€β”€ with-images/
β”‚   β”‚   β”œβ”€β”€ README.md                  # Image example overview
β”‚   β”‚   β”œβ”€β”€ visual-guide.md            # Document with images
β”‚   β”‚   └── images/
β”‚   β”‚       └── sample.png             # Sample image
β”‚   └── technical-spec/
β”‚       β”œβ”€β”€ README.md                  # Technical doc overview
β”‚       └── specification.md           # Technical specification
└── assets/
    β”œβ”€β”€ css/
    β”‚   β”œβ”€β”€ README.md                  # CSS guide
    β”‚   β”œβ”€β”€ professional-theme.css     # Business theme
    β”‚   β”œβ”€β”€ technical-theme.css        # Technical docs theme
    β”‚   β”œβ”€β”€ minimal-theme.css          # Minimal clean theme
    β”‚   └── executive-theme.css        # Executive reports theme
    └── images/
        β”œβ”€β”€ logo.png                   # Example logo
        └── banner.png                 # Example banner

🎯 Common Patterns

Documentation Site

- uses: MystaMax/markdown-to-pdf@v1
  with:
      source-dir: 'docs'
      include-patterns: '**/*.md'
      exclude-patterns: '**/README.md'
      css-file: 'assets/css/professional-theme.css'
      include-toc: true

API Documentation

- uses: MystaMax/markdown-to-pdf@v1
  with:
      include-patterns: 'api-docs/**/*.md'
      css-file: 'assets/css/technical-theme.css'
      paper-size: 'Letter'
      orientation: 'landscape'

Release Notes

on:
    release:
        types: [published]

- uses: MystaMax/markdown-to-pdf@v1
  with:
      include-patterns: 'CHANGELOG.md'
      title: 'Release ${{ github.event.release.tag_name }}'
      artifact-name: 'release-notes-${{ github.event.release.tag_name }}'

πŸ”§ Troubleshooting

No PDFs Generated

  • Check the workflow logs for errors
  • Verify your file patterns match existing files
  • Ensure the action has proper permissions

Styling Not Applied

  • Verify CSS file path is correct (relative to repository root)
  • Check CSS syntax with a validator
  • Use browser dev tools to test styles

Large File Warnings

  • Consider splitting large documents
  • Optimize images (compress, resize)
  • Process files in batches

More Help

🀝 Contributing Examples

Have a great use case? Contributions are welcome!

  1. Fork this repository
  2. Add your example workflow and/or sample documents
  3. Update this README with your example
  4. Submit a pull request

πŸ“ License

This example repository is provided as-is for demonstration purposes. The markdown-to-pdf-action itself is licensed under MIT.

πŸ”— Links


Happy PDF generation! πŸ“„βœ¨

About

Example repository demonstrating the markdown-to-pdf-action with comprehensive workflow examples, sample documents, and custom themes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published