Skip to content

Create test.cgel

Create test.cgel #11

Workflow file for this run

# 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
on:
pull_request:
paths:
- datasets/oneoff/*.cgel
branches: [ "main" ]
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/get-changed-files@25f79e676e7ea1868813e21465014798211fad8c
id: files
with:
format: space-delimited
- name: Check out the pull request
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
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: |
python -m pip install --upgrade pip
pip install -r cgel/requirements.txt
- 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
filename=$(basename "$changed_file")
tree_name="${filename%.cgel}"
# make .tex
python cgel/tree2tex.py "${changed_file}" > "datasets/oneoff/tex/$tree_name.tex"
git add "datasets/oneoff/tex/$tree_name.tex"
# 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 tex and pdf files for $filename"
fi
done
git push origin HEAD:${{ github.event.pull_request.head.ref }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}