File tree Expand file tree Collapse file tree 1 file changed +69
-0
lines changed
Expand file tree Collapse file tree 1 file changed +69
-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' # Only run if Markdown files change
9+ - ' !.github/**' # Don't run if only workflow files change
10+
11+ # This prevents multiple runs from overlapping if you push rapidly
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@v3
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+ find . -type f \( -iname "*.md" ! -iname "README.md" \) | while read f; do
34+ pandoc "$f" -s -o "output/${f%.md}.pdf" --toc --number-sections --verbose
35+ done
36+
37+ - uses : actions/upload-artifact@v3
38+ with :
39+ name : output
40+ path : output
41+
42+ pushpdfs :
43+ needs : makepdfs
44+ runs-on : ubuntu-latest
45+ # Added a check to ensure the bot doesn't trigger itself
46+ if : github.actor != 'github-actions[bot]'
47+
48+ steps :
49+ - uses : actions/checkout@v3
50+
51+ - name : Download all workflow run artifacts
52+ uses : actions/download-artifact@v3
53+ with :
54+ name : output
55+ path : pdf
56+
57+ - name : Add and commit files
58+ run : |
59+ git config --global user.name github-actions[bot]
60+ git config --global user.email github-actions[bot]@users.noreply.github.com
61+
62+ # Check if there are actually changes to avoid empty commit errors
63+ git add pdf/*.pdf
64+ if git diff --staged --quiet; then
65+ echo "No changes to commit"
66+ else
67+ git commit -m "Auto update pdfs [skip ci]" -a
68+ git push
69+ fi
You can’t perform that action at this time.
0 commit comments