File tree Expand file tree Collapse file tree 1 file changed +78
-0
lines changed
Expand file tree Collapse file tree 1 file changed +78
-0
lines changed Original file line number Diff line number Diff line change 1+ name : create PDF workflow
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths :
8+ - ' **.md'
9+ - ' !.github/**'
10+
11+ # Prevents multiple runs from overlapping
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.ref }}
14+ cancel-in-progress : true
15+
16+ jobs :
17+ makepdfs :
18+ runs-on : ubuntu-latest
19+ container :
20+ image : docker://pandoc/latex:2.9
21+
22+ steps :
23+ - uses : actions/checkout@v4
24+
25+ - name : prepare output directories
26+ run : |
27+ for d in */; do
28+ mkdir -p output/"$d"
29+ done
30+
31+ - name : create pdf file(s)
32+ run : |
33+ # The --pdf-engine=xelatex flag allows for Unicode characters like ≤
34+ find . -type f \( -iname "*.md" ! -iname "README.md" \) | while read f; do
35+ pandoc "$f" -s -o "output/${f%.md}.pdf" \
36+ --toc \
37+ --number-sections \
38+ --pdf-engine=xelatex \
39+ --verbose
40+ done
41+
42+ - uses : actions/upload-artifact@v4
43+ with :
44+ name : output
45+ path : output
46+
47+ pushpdfs :
48+ needs : makepdfs
49+ runs-on : ubuntu-latest
50+ # Explicitly grant permission to write (push) to the repository
51+ permissions :
52+ contents : write
53+
54+ # Safety check to prevent the bot from triggering its own workflow
55+ if : github.actor != 'github-actions[bot]'
56+
57+ steps :
58+ - uses : actions/checkout@v4
59+
60+ - name : Download all workflow run artifacts
61+ uses : actions/download-artifact@v4
62+ with :
63+ name : output
64+ path : pdf
65+
66+ - name : Add and commit files
67+ run : |
68+ git config --global user.name github-actions[bot]
69+ git config --global user.email github-actions[bot]@users.noreply.github.com
70+
71+ git add pdf/*.pdf
72+ if git diff --staged --quiet; then
73+ echo "No changes to commit"
74+ else
75+ # [skip ci] tells GitHub not to run the workflow again for this specific commit
76+ git commit -m "Auto update pdfs [skip ci]" -a
77+ git push
78+ fi
You can’t perform that action at this time.
0 commit comments