generated from PreTeXtBook/pretext-codespace
-
Notifications
You must be signed in to change notification settings - Fork 3
147 lines (125 loc) · 4.63 KB
/
pretext-cli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: PreTeXt-CLI Actions
on:
# Runs on pull requests
pull_request:
branches: ["*"]
# Runs on pushes to main
push:
branches: ["main"]
# Runs on demand
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
container: oscarlevin/pretext:full
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
apt-get update
apt-get install -y inkscape
shell: bash
- name: Verify Inkscape Installation
run: inkscape --version
- name: install deps
run: |
pip install -r requirements.txt
pretext --version
- name: ensure proper asset type in image references
run: ./update-img-refs.py source/ --to-svg
- name: build deploy targets
run: |
version="$(pretext --version)"
major="$(echo $version | cut -d '.' -f 1)"
minor="$(echo $version | cut -d '.' -f 2)"
if [ "$major" -ge 2 -a "$minor" -ge 5 ]; then
echo "PreTeXt version is 2.5 or greater; using new build command"
pretext build --deploys
else
echo "PreTeXt version is less than 2.5, using old build command"
pretext build
fi
- name: stage deployment
run: pretext deploy --stage-only
- name: Bundle output/stage as artifact
uses: actions/upload-artifact@v4
with:
name: deploy
path: output/stage
- name: ensure proper asset type in image references for pdf output
run: |
make svg-to-pdf
./update-img-refs.py source/ --to-pdf
- name: Build PDF with PreTeXt
run: pretext build print
- name: Bundle output/print as PDF artifact
uses: actions/upload-artifact@v4
with:
name: pdf
path: output/print
deploy-ghpages:
runs-on: ubuntu-latest
needs: build
if: vars.PTX_ENABLE_DEPLOY_GHPAGES == 'yes' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "page"
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download website artifact
uses: actions/download-artifact@v4
with:
name: deploy
path: deploy
- name: Setup GitHub Pages
id: check
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: deploy
- name: Deploy to Github Pages
id: deployment
uses: actions/deploy-pages@v4
update-pdf:
runs-on: ubuntu-latest
needs: build
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
permissions:
contents: write
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Fetch and switch to main branch
run: |
git fetch origin
git checkout main
git reset --hard origin/main
- name: Download PDF artifact
uses: actions/download-artifact@v4
with:
name: pdf
path: output/print
- name: Create or update pdf-update branch from main
run: git checkout -B pdf-update
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Commit changes
run: |
git add output/print/discrete-math-with-sage.pdf
git commit -m "Update PDF" || echo "No changes to commit"
- name: Force push to pdf-update branch
run: git push origin pdf-update --force