jp font
Build LaTeX PDF / build (push) Failing after 2m30s

This commit is contained in:
Domipoke
2026-07-27 17:31:52 +02:00
parent 91bd628b5a
commit 86cd95e5d0
3 changed files with 6 additions and 202 deletions
-200
View File
@@ -1,200 +0,0 @@
name: Build LaTeX PDF
# on:
# push:
# paths:
# - '**/*.tex'
jobs:
build:
runs-on: ubuntu-latest
env:
GIT_SSL_NO_VERIFY: "true"
NODE_EXTRA_CA_CERTS: /usr/local/share/ca-certificates/Egregge.crt
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2 # need previous commit to diff against
- name: Find changed .tex root files
id: changed
run: |
apt-get update -qq && apt-get install -y -qq git > /dev/null
git config --global --add safe.directory "$GITHUB_WORKSPACE"
# root files = .tex files that contain \documentclass
CHANGED=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- '*.tex' || true)
ROOTS=""
for f in $CHANGED; do
if [ -f "$f" ] && grep -q '\\documentclass' "$f"; then
ROOTS="$ROOTS $f"
fi
done
echo "roots=$ROOTS" >> "$GITHUB_OUTPUT"
echo "Root files to build: $ROOTS"
- name: Compile changed root files
if: steps.changed.outputs.roots != ''
uses: docker://texlive/texlive:latest-full
with:
entrypoint: sh
args: >-
-c "mkdir -p pdf aux && for f in ${{ steps.changed.outputs.roots }}; do
echo Building $f;
latexmk -pdf -interaction=nonstopmode -halt-on-error -outdir=pdf -auxdir=aux \"$f\" || exit 1;
done && find pdf -type f ! -name '*.pdf' -delete"
- name: Upload built PDFs
if: steps.changed.outputs.roots != ''
uses: actions/upload-artifact@v3
with:
name: pdf-output
path: pdf/*.pdf
- name: Commit PDFs back to repo
if: steps.changed.outputs.roots != ''
run: |
git config user.name "gitea-actions"
git config user.email "actions@gitea.local"
git remote set-url origin "https://Domipoke:${{ secrets.GITEA_PUSH_TOKEN }}@gitea.egregge.eg/Domipoke/SharedLaTeX.git"
git add pdf/*.pdf
git diff --cached --quiet || git commit -m "CI: rebuild PDF(s) [skip ci]"
git push origin HEAD:${{ github.ref_name }}
this see no update if i use in main file \input{./chapt/...} and edit only file in chapt folder that i push; then also do not update the right branch where i pushed commit
Mostra meno
Architected dependency graph solution for nested LaTeX files and branch detection
Architected dependency graph solution for nested LaTeX files and branch detection
You've hit two separate bugs. Let me break down each one.
Bug 1: chapter edits don't trigger a build
Your detection logic is:
bash
CHANGED=$(git diff --name-only ... -- '*.tex')
for f in $CHANGED; do
if grep -q '\documentclass' "$f"; then
ROOTS="$ROOTS $f"
fi
done
This only adds a file to ROOTS if the changed file itself contains \documentclass. When you edit chapt/foo.tex and it gets pulled in via \input{./chapt/foo} from main.tex, chapt/foo.tex obviously has no \documentclass in it — so it's silently dropped, ROOTS stays empty, and the two if: steps.changed.outputs.roots != '' steps just skip.
You need to invert the logic: find all root files in the repo, resolve each one's \input/\include dependency tree, and rebuild any root whose tree intersects the changed-files set.
Bug 2: pushes go to the wrong branch
git push origin HEAD:${{ github.ref_name }} relies on github.ref_name being populated correctly. Gitea Actions' GitHub-compatibility shim doesn't always populate ref_name reliably (especially depending on runner/Gitea version), so this can silently resolve to the wrong value (e.g. the default branch) instead of the branch you actually pushed to. It's safer to derive the branch explicitly from GITHUB_REF, which is more consistently set:
bash
BRANCH="${GITHUB_REF#refs/heads/}"
git push origin HEAD:refs/heads/"$BRANCH"
Also worth guarding: fetch-depth: 2 + github.event.before breaks on the very first push to a branch (before-sha is all zeros), which would make the diff step fail/empty too — separate failure mode, same symptom (nothing gets built).
Fixed workflow
yaml
name: Build LaTeX PDF
on:
push:
paths:
- '**/*.tex'
jobs:
build:
runs-on: ubuntu-latest
env:
GIT_SSL_NO_VERIFY: "true"
NODE_EXTRA_CA_CERTS: /usr/local/share/ca-certificates/Egregge.crt
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history, safer for diffing
- name: Find root files affected by this push
id: changed
run: |
apt-get update -qq && apt-get install -y -qq git > /dev/null
git config --global --add safe.directory "$GITHUB_WORKSPACE"
BEFORE="${{ github.event.before }}"
AFTER="${{ github.sha }}"
# Handle first push to a branch (before = all zeros)
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ] || [ -z "$BEFORE" ]; then
CHANGED=$(git ls-tree -r --name-only "$AFTER" -- '*.tex')
else
CHANGED=$(git diff --name-only "$BEFORE" "$AFTER" -- '*.tex' || true)
fi
echo "Changed .tex files: $CHANGED"
# All root files (anywhere in repo) containing \documentclass
ALL_ROOTS=$(grep -rl '\\documentclass' --include='*.tex' . | sed 's|^\./||')
# Recursively resolve \input/\include/\subfile deps of a root,
# printing paths relative to repo root
resolve_deps() {
local file="$1"
local dir
dir=$(dirname "$file")
[ -f "$file" ] || return
echo "$file"
grep -ohE '\\(input|include|subfile)\{[^}]*\}' "$file" 2>/dev/null \
| sed -E 's/.*\{([^}]*)\}/\1/' \
| while read -r inc; do
[[ "$inc" != *.tex ]] && inc="${inc}.tex"
full=$(realpath --relative-to=. "$dir/$inc" 2>/dev/null)
[ -n "$full" ] && resolve_deps "$full"
done
}
ROOTS=""
for root in $ALL_ROOTS; do
DEPS=$(resolve_deps "$root" | sort -u)
HIT=""
for c in $CHANGED; do
if grep -qxF "$c" <<< "$DEPS"; then
HIT=1
break
fi
done
if [ -n "$HIT" ]; then
ROOTS="$ROOTS $root"
fi
done
echo "roots=$ROOTS" >> "$GITHUB_OUTPUT"
echo "Root files to build: $ROOTS"
- name: Compile changed root files
if: steps.changed.outputs.roots != ''
uses: docker://texlive/texlive:latest-full
with:
entrypoint: sh
args: >-
-c "mkdir -p pdf aux && for f in ${{ steps.changed.outputs.roots }}; do
echo Building $f;
latexmk -pdf -interaction=nonstopmode -halt-on-error -outdir=pdf -auxdir=aux \"$f\" || exit 1;
done && find pdf -type f ! -name '*.pdf' -delete"
- name: Upload built PDFs
if: steps.changed.outputs.roots != ''
uses: actions/upload-artifact@v3
with:
name: pdf-output
path: pdf/*.pdf
- name: Commit PDFs back to repo
if: steps.changed.outputs.roots != ''
run: |
git config user.name "gitea-actions"
git config user.email "actions@gitea.local"
git remote set-url origin "https://Domipoke:${{ secrets.GITEA_PUSH_TOKEN }}@gitea.egregge.eg/Domipoke/SharedLaTeX.git"
BRANCH="${GITHUB_REF#refs/heads/}"
echo "Pushing to branch: $BRANCH"
git add pdf/*.pdf
git diff --cached --quiet || git commit -m "CI: rebuild PDF(s) [skip ci]"
git push origin HEAD:refs/heads/"$BRANCH"
Submodule fonts/HaranoAjiFonts added at f0f692c1e3
+5 -2
View File
@@ -12,7 +12,7 @@
\usepackage{xeCJK} \usepackage{xeCJK}
% JP Font % JP Font
\setCJKmainfont{HaranoAjiMincho-Regular} \setCJKmainfont{HaranoAjiGothic-Medium.otf}[Path=./fonts/HaranoAjiFonts]
% other package % other package
\usepackage{lmodern} \usepackage{lmodern}
@@ -122,8 +122,11 @@ delim_0 ",\~"
\setkomafont{dictumtext}{\itshape\small} \setkomafont{dictumtext}{\itshape\small}
\setkomafont{dictumauthor}{\itshape\small} \setkomafont{dictumauthor}{\itshape\small}
%% Emoji %% Emoji
\newcommand{\heart}{{\fontspec{Symbola.ttf}[Path=./fonts/]\symbol{"1FA77}}} % \newcommand{\heart}{{\fontspec{Symbola.ttf}[Path=./fonts/]\symbol{"1FA77}}}
% \newcommand{\heart}{\color{pink}\faHeart} % \newcommand{\heart}{\color{pink}\faHeart}
\usepackage{emoji}
\newcommand{\heart}{\emoji{pink-heart}}
%% %%
\title{Letteratura Giapponese I} \title{Letteratura Giapponese I}
\author{Marianna} \author{Marianna}