Update main.yml #94
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate PDF | |
| on: | |
| push: | |
| branches: [ pdf ] | |
| # paths: | |
| # - 'doc/**' # Trigger when docs are updated | |
| jobs: | |
| convert_to_pdf: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install pandoc and LaTeX | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y pandoc texlive-xetex texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra tree | |
| - name: Generate documentation tree in Markdown | |
| run: | | |
| tree doc -I 'node_modules|.git' -L 2 --noreport --charset ascii > tree.md | |
| - name: Remove file extensions from tree.md | |
| run: | | |
| sed -i 's/\(.*\)\.[^.]*$/\1/' tree.md | |
| - name: Format tree.md for Markdown | |
| run: | | |
| sed -i 's/^/ /' tree.md | |
| - name: Merge Markdown files and insert tree | |
| run: | | |
| touch combined.md | |
| echo "# Document Structure" > combined.md | |
| cat tree.md >> combined.md | |
| echo "" >> combined.md | |
| # Find and sort README.md files first, excluding doc/readme.md | |
| find doc -type f -name "readme.md" ! -path "doc/readme.md" | sort | while read -r file; do | |
| echo "Processing $file" | |
| cat "$file" >> combined.md | |
| echo "" >> combined.md | |
| done | |
| # Add doc/readme.md after other README.md files | |
| if [ -f "doc/readme.md" ]; then | |
| echo "Processing doc/readme.md" | |
| cat "doc/readme.md" >> combined.md | |
| echo "" >> combined.md | |
| fi | |
| # Find and sort other .md files | |
| find doc -type f -name "*.md" ! -name "readme.md" ! -name "doc-tree.md" | sort | while read -r file; do | |
| echo "Processing $file" | |
| cat "$file" >> combined.md | |
| echo "" >> combined.md | |
| done | |
| - name: Convert README.md to README.pdf | |
| run: pandoc combined.md -o README.pdf --pdf-engine=xelatex | |
| - name: Upload PDF | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: documentation-pdfs | |
| path: README.pdf |