Skip to content

PR #13: ci: mejoras en workflows de build y release #48

PR #13: ci: mejoras en workflows de build y release

PR #13: ci: mejoras en workflows de build y release #48

Workflow file for this run

name: Build LaTeX Document
# Run name dinámico para mejor visibilidad en la UI
run-name: >-
${{ github.event_name == 'pull_request'
&& format('PR #{0}: {1}', github.event.pull_request.number, github.event.pull_request.title)
|| format('Build: {0}', github.event.head_commit.message || 'Manual trigger') }}
on:
push:
branches: [ main ]
# Solo compilar si hay cambios relevantes (no solo docs)
paths:
- '**.tex'
- '**.sty'
- '**.cls'
- '**.bib'
- 'recursos/**'
- 'contenido/**'
- '.latexmkrc'
- '.github/workflows/build.yml'
pull_request:
branches: [ main ]
paths:
- '**.tex'
- '**.sty'
- '**.cls'
- '**.bib'
- 'recursos/**'
- 'contenido/**'
- '.latexmkrc'
- '.github/workflows/build.yml'
workflow_dispatch:
permissions:
contents: read
pull-requests: write
# Control de concurrencia: cancela builds anteriores del mismo PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
TEXLIVE_VERSION: "2025"
jobs:
build:
name: Compilar documento LaTeX
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Instalar TeX Live y dependencias
run: |
sudo apt-get update
sudo apt-get install -y texlive-full latexmk python3-pip
pip install --break-system-packages latexminted
lualatex --version | head -2
- name: Compilar documento LaTeX
run: |
latexmk -lualatex -shell-escape -interaction=nonstopmode main.tex
- name: Upload PDF artifact
uses: actions/upload-artifact@v6
with:
name: TFG-TFM_EPS_UA
path: main.pdf
retention-days: 90
- name: Upload log on failure
if: failure()
uses: actions/upload-artifact@v6
with:
name: build-logs
path: |
*.log
*.blg
retention-days: 7
comment-pr:
name: Comentar en PR
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
needs: build
steps:
- name: Comment on PR
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const prNumber = context.issue.number;
const sha = context.payload.pull_request.head.sha.substring(0, 7);
const body = `## 📄 Compilación del documento
✅ El documento **main.pdf** se ha compilado correctamente.
| Detalle | Valor |
|---------|-------|
| **Commit** | \`${sha}\` |
| **PR** | #${prNumber} |
| **TeX Live** | ${{ env.TEXLIVE_VERSION }} |
### 📥 Descargar PDF
👉 **[Ver workflow y descargar artefactos](${runUrl})**
En la sección "Artifacts" encontrarás el archivo **TFG-TFM_EPS_UA** con el PDF compilado.
> **Nota:** Los artefactos estarán disponibles durante 90 días.
---
*Generado automáticamente por GitHub Actions* 🤖
`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📄 Compilación del documento')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
}
check-links:
name: Verificar enlaces
runs-on: ubuntu-latest
# Solo ejecutar si hay cambios en archivos markdown
if: >-
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.modified, '.md') ||
github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Check README links
uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
use-quiet-mode: 'yes'
config-file: '.github/mlc_config.json'
continue-on-error: true