Skip to content

Coherent X-ray Scattering from an Atom #27

Coherent X-ray Scattering from an Atom

Coherent X-ray Scattering from an Atom #27

Workflow file for this run

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
if: github.repository_owner == 'janosh' # don't run on forks
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"
echo "::set-output name=tex-files::$tex_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: Run render-tikz.py on changed TeX files
if: steps.diff.outputs.tex-files != ''
id: render-tikz
run: |
for tex_file in ${{ steps.diff.outputs.tex-files }}; do
echo "Processing $tex_file..."
./scripts/render-tikz.py "$tex_file"
done
- name: Push changes if any
if: steps.render-tikz.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