Add descriptions to 18 more diagrams #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update PDF, PNG and SVG assets for changed TeX files | |
on: | |
pull_request: | |
branches: [main] | |
paths: [assets/**/*.tex] | |
jobs: | |
update-assets: | |
name: Update assets | |
runs-on: ubuntu-latest | |
# don't run on forks and only if PR was opened from branch on this repo | |
if: github.repository_owner == 'janosh' && github.event.pull_request.head.repo.fork == false | |
steps: | |
- name: Check out repo | |
uses: actions/checkout@v4 | |
with: | |
# get full history to include BASE_REF commit where PR branched off | |
fetch-depth: 0 | |
- name: Get changed TeX files | |
id: diff | |
run: | | |
BASE_REF=${{ github.event.before }} | |
git fetch origin $BASE_REF --depth=1 | |
echo "TeX files changed between BASE_REF=$BASE_REF and SHA=$GITHUB_SHA:" | |
tex_files=$(git diff --name-only $BASE_REF $GITHUB_SHA | grep .tex$ | xargs) | |
echo "$tex_files" | |
typst_files=$(git diff --name-only $BASE_REF $GITHUB_SHA | grep .typ$ | xargs) | |
echo "$typst_files" | |
echo "::set-output name=tex-files::$tex_files" | |
echo "::set-output name=typst-files::$typst_files" | |
- name: Install compression deps | |
if: steps.diff.outputs.tex-files != '' | |
run: | | |
sudo apt-get install -y pdf2svg imagemagick pngquant zopfli | |
sudo snap install svgo | |
pip install pdf-compressor | |
pdf-compressor --set-api-key ${{ secrets.ILOVEPDF_PUBLIC_KEY }} | |
- name: Install TeX Live | |
if: steps.diff.outputs.tex-files != '' | |
# texlive-latex-extra is needed for package standalone | |
run: sudo apt-get install texlive latexmk texlive-latex-base texlive-latex-extra | |
- name: Install Typst | |
if: steps.diff.outputs.typst-files != '' | |
uses: typst-community/setup-typst@v3 | |
- name: Run render_(typst|tikz).py on changed TeX files | |
if: steps.diff.outputs.tex-files != '' | |
id: render-diagrams | |
run: | | |
for tex_file in ${{ steps.diff.outputs.tex-files }}; do | |
echo "Processing $tex_file..." | |
python scripts/render_tikz.py "$tex_file" | |
done | |
for typst_file in ${{ steps.diff.outputs.typst-files }}; do | |
echo "Processing $typst_file..." | |
python scripts/render_typst.py "$typst_file" | |
done | |
- name: Push changes if any | |
if: steps.render-diagrams.outcome == 'success' | |
run: | | |
git config user.name 'Janosh Riebesell' | |
git config user.email [email protected] | |
git checkout ${{ github.head_ref }} | |
git add assets/**/*.{pdf,svg,png} | |
git commit -m 'assets for ${{ steps.diff.outputs.tex-files }}' | |
git push |