Skip to content

Update 12-3.cgel

Update 12-3.cgel #36

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:
push:
paths:
- datasets/oneoff/*.cgel
branches-ignore:
- main
jobs:
init:
runs-on: ubuntu-latest
permissions:
contents: none
steps:
- name: run a trivial bash command
run: echo "initializing conversion"
render:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
submodules: true
- name: Update to make sure we have a newly created branch
run: |
git branch -v
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - name: Get name of branch's parent branch
# run: |
# echo "PARENT_BRANCH=$(git for-each-ref --format=\"%(refname:short)\" refs/heads/ | while read branch; do
# echo \"$(git merge-base HEAD $branch) $branch\"
# done | sort -r | head -n 1 | awk \"{print $2}\")" >> $GITHUB_ENV
# # https://github.com/trilom/file-changes-action/issues/116#issuecomment-790007782
# - name: Get changed files
# run: |
# # check to see if there's a previous commit on the branch
# # if not, then diff with the parent branch
# # if yes, then diff with the HEAD @ prevous commit
# if [[ -z "${{ github.event.before_ref }}" ]] ; then
# export DIFF=$( git diff --name-only $PARENT_BRANCH ${{ github.sha }} )
# echo "Diff between $PARENT_BRANCH and ${{ github.sha }} "
# else
# export DIFF=$( git diff --name-only ${{ github.event.before }} ${{ github.sha }} )
# echo "Diff between ${{ github.event.before }} and ${{ github.sha }} "
# fi
# echo "::set-output name=files::$( echo "$DIFF" | sed ':a;N;$!ba;s/\n/%0A/g' )"
# https://github.com/Ana06/get-changed-files/releases/tag/v1.2
- uses: Ana06/get-changed-files@25f79e676e7ea1868813e21465014798211fad8c
id: files
with:
format: space-delimited
- name: Config github actions bot
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
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
run: |
mkdir -p datasets/oneoff/tex
mkdir -p datasets/oneoff/pdf
for changed_file in ${{ steps.getfile.outputs.files }}; 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"
# make .pdf
pdflatex -output-directory=datasets/oneoff/pdf "datasets/oneoff/tex/$tree_name.tex"
fi
done
- name: Commit and push .tex and .pdf files
run: |
for changed_file in ${{ steps.getfile.outputs.files }}; do
if [[ "$changed_file" == **.cgel ]]; then
filename=$(basename "$changed_file")
tree_name="${filename%.cgel}"
git add "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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}