Skip to content

Commit

Permalink
Merge pull request #58 from ZEISS/20240909-feat-md2pdf
Browse files Browse the repository at this point in the history
Add GitHub Action to convert Releasenotes.md to PDF
  • Loading branch information
mprinkezs committed Sep 11, 2024
2 parents 65c8934 + 01fd97d commit 6c8d4e6
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
14 changes: 14 additions & 0 deletions .github/scripts/md2pdf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# md2pdf.py
#
# Carl Zeiss GOM Metrology GmbH, 2024
#
# ---
'''Convert Markdown document to PDF'''
import sys
from markdown_pdf import MarkdownPdf, Section

pdf = MarkdownPdf(toc_level=4)
pdf.add_section(Section(open(sys.argv[1], encoding='utf-8').read(), toc=False), user_css="body {font-family: sans-serif;}")
pdf.meta["title"] = "Releasenotes"
pdf.save(sys.argv[2])
18 changes: 10 additions & 8 deletions .github/workflows/releasenotes_pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Pandoc
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install markdown_pdf
run: |
sudo apt-get update
# Install pdflatex as prerequisite for pandoc PDF output
sudo apt-get install -y texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
sudo apt-get install -y pandoc
pip install markdown_pdf
- name: Find and Convert Release Notes
id: convert_notes
run: |
Expand All @@ -29,11 +31,11 @@ jobs:
basepath=$(dirname "{}") # Get the folder path
echo $basepath
if [ ! -f "$basepath/Releasenotes.pdf" ]; then
pandoc --variable mainfont="Arial" "{}" -o "$basepath/Releasenotes.pdf"
python .github/scripts/md2pdf.py "{}" "$basepath/Releasenotes.pdf"
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git add "$basepath/Releasenotes.pdf"
git commit -m "Add Releasenotes.pdf"
git push origin main
git push origin ${GITHUB_REF#refs/*/}
fi
' \;
Binary file modified AppExamples/dialog_widgets/DropdownWidget/doc/Releasenotes.pdf
Binary file not shown.
Binary file modified AppExamples/script_resources/ResourceAccess/doc/Releasenotes.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 6c8d4e6

Please sign in to comment.