-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (63 loc) · 2.41 KB
/
tex-pdf.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
# add .tex conversion and (and .pdf rendering of .tex file) to a pull request that adds/modifies a cgel tree.
# currently assumes cgel file(s) in datasets/oneoff.
name: Create tree .tex and .pdf
permissions:
contents: write
pull-requests: write
repository-projects: write
on:
pull_request:
paths:
- datasets/oneoff/*.cgel
jobs:
render:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
# https://github.com/Ana06/get-changed-files/releases/tag/v1.2
- uses: Ana06/[email protected]
id: files
with:
format: space-delimited
token: ${{ secrets.GITHUB_TOKEN }}
- name: Check out the pull request
run: gh pr checkout ${{ github.event.pull_request.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install cgel dependencies
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
python -m pip install --upgrade pip
pip install -r cgel/requirements.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Install texlive
run: sudo apt-get install texlive-latex-extra
- name: Generate .tex and .pdf files and commit
run: |
mkdir -p datasets/oneoff/tex
mkdir -p datasets/oneoff/pdf
for changed_file in ${{ steps.files.outputs.added_modified }}; do
if [[ "$changed_file" == **.cgel ]]; then
# make .tex
filename=$(basename "$changed_file")
tree_name="${filename%.cgel}"
python cgel/tree2tex.py ${changed_file} > datasets/oneoff/tex/$tree_name.tex
git add datasets/oneoff/tex/$tree_name.tex
git commit -m "generated tex file for $filename"
# make .pdf
pdflatex -output-directory=datasets/oneoff/pdf datasets/oneoff/tex/$tree_name.tex
git add datasets/oneoff/pdf/$tree_name.pdf
git commit -m "generated pdf file for $filename"
fi
done
git push origin HEAD:${{ github.event.pull_request.head.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}