11name : Generate PDF
22
33on :
4- # allows manual triggering of the workflow
4+ # allows manual triggering
55 workflow_dispatch :
6- # run on changes to main
76 push :
87 branches :
9- - main
10- # run on PRs to main
8+ - ' **'
119 pull_request :
1210 branches :
13- - main
11+ - ' ** '
1412
1513jobs :
16- build :
14+
15+ # runs on main branch pushes
16+ build-and-deploy :
17+ if : github.ref == 'refs/heads/main'
1718 runs-on : ubuntu-latest
18- # grant GITHUB_TOKEN permissions for pages deployment
1919 permissions :
20+ contents : write
2021 pages : write
2122 id-token : write
2223 environment :
2324 name : github-pages
2425 url : ${{ steps.deployment.outputs.page_url }}
26+ steps :
27+ - name : Checkout Repo
28+ uses : actions/checkout@v4
29+
30+ - name : Build PDF
31+ uses : xu-cheng/latex-action@v4
32+ with :
33+ root_file : M17_spec.tex
34+
35+ - name : Check PDF exists
36+ run : |
37+ if [ ! -f M17_spec.pdf ]; then
38+ echo "PDF was not generated!" >&2
39+ exit 1
40+ fi
41+ - name : Move PDF to public/
42+ run : |
43+ mkdir -p public
44+ mv M17_spec.pdf public/
45+
46+ - name : Setup Pages
47+ uses : actions/configure-pages@v4
2548
49+ - name : Upload PDF
50+ uses : actions/upload-pages-artifact@v3
51+ with :
52+ path : public
53+
54+ - name : Deploy to Pages
55+ uses : actions/deploy-pages@v4
56+
57+ - name : Post URL to Summary
58+ run : echo "🚀 [View the latest PDF](https://m17-project.github.io/M17_spec/M17_spec.pdf)" >> $GITHUB_STEP_SUMMARY
59+
60+ # runs on PRs and non-main branch pushes
61+ build-artifact-only :
62+ if : github.ref != 'refs/heads/main'
63+ runs-on : ubuntu-latest
64+ permissions :
65+ contents : write
2666 steps :
27- - name : Checkout
67+ - name : Checkout Repo
2868 uses : actions/checkout@v4
2969
30- - name : Build
31- # wraps a LaTeX build environment
70+ - name : Build PDF
3271 uses : xu-cheng/latex-action@v4
3372 with :
3473 root_file : M17_spec.tex
3574
36- - name : Upload
75+ - name : Check PDF exists
76+ run : |
77+ if [ ! -f M17_spec.pdf ]; then
78+ echo "PDF was not generated!" >&2
79+ exit 1
80+ fi
81+
82+ - name : Upload PDF artifact for branch/PR
3783 uses : actions/upload-artifact@v4
3884 with :
39- name : Specification
85+ name : M17_spec
4086 path : M17_spec.pdf
41-
42- - name : Deploy
43- # only deploy on pushes to main, not on PRs
44- if : github.event_name == 'push' && github.ref == 'refs/heads/main'
45- uses : actions/deploy-pages@v4
0 commit comments