Skip to content

Merge pull request #12 from CSchank/only-commit-changed #6

Merge pull request #12 from CSchank/only-commit-changed

Merge pull request #12 from CSchank/only-commit-changed #6

Workflow file for this run

name: buildtex
on:
push:
branches: main
paths: [docs/**]
pull_request:
branches: main
paths: [docs/**]
permissions:
contents: write
jobs:
compile-latex:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed LaTeX files
id: latex-files
run: |
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- docs/**/*.tex | xargs)
echo "Changed files: $CHANGED_FILES"
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV
CHANGED_FILENAMES=$(for file in $CHANGED_FILES; do basename "$file"; done | xargs)
echo "CHANGED_FILENAMES=$CHANGED_FILENAMES" >> $GITHUB_ENV
FILE_COUNT=$(echo $CHANGED_FILENAMES | wc -w)
if [ $FILE_COUNT -gt 1 ]; then
PLURAL_S='s'
else
PLURAL_S=''
fi
echo "PLURAL_S=$PLURAL_S" >> $GITHUB_ENV
- uses: xu-cheng/texlive-action@v2
name: Compile LaTeX Files
with:
scheme: full
texlive_version: 2024
run: |
apk add make
cd docs
for file in ${{ env.CHANGED_FILES }}; do
dir=$(dirname "$file" | cut -d'/' -f2-)
make -B "$dir/$(basename "$file" .tex).pdf"
done
- name: Commit and push PDFs
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Add/Update PDF${{ env.PLURAL_S }} for changed LaTeX file${{ env.PLURAL_S }}: ${{ env.CHANGED_FILENAMES }}'
file_pattern: 'docs/*.pdf'
branch: main