84 lines
2.8 KiB
YAML
84 lines
2.8 KiB
YAML
# Builds the DevOps IT manual (manual/) into a PDF on every push to main
|
|
# that touches the manual or this workflow, and uploads it as an artifact.
|
|
name: Build IT manual
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- 'manual/**'
|
|
- '.gitea/workflows/manual.yml'
|
|
workflow_dispatch: # lets a team member re-run a build by hand from the Actions tab
|
|
|
|
jobs:
|
|
build-manual:
|
|
# Runner label registered in Part 2. The label maps to the job image built
|
|
# from manual/ci/Dockerfile (TeX Live + Node.js), so each job runs in a
|
|
# fresh, temporary container -- never inside the Gitea container.
|
|
runs-on: latex
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
steps:
|
|
- name: Check out the triggering commit
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Generate build metadata
|
|
working-directory: manual
|
|
env:
|
|
GIT_COMMIT: ${{ github.sha }}
|
|
BUILD_NUMBER: ${{ github.run_number }}
|
|
run: |
|
|
MANUAL_VERSION="v1.4"
|
|
SHORT_SHA="${GIT_COMMIT:0:7}"
|
|
BUILD_ID="${MANUAL_VERSION}+build.${BUILD_NUMBER}.${SHORT_SHA}"
|
|
|
|
cat > build-metadata.tex <<EOF
|
|
\newcommand{\ManualVersion}{${MANUAL_VERSION}}
|
|
\newcommand{\BuildIdentifier}{${BUILD_ID}}
|
|
\newcommand{\BuildCommit}{${GIT_COMMIT}}
|
|
\newcommand{\BuildRunNumber}{${BUILD_NUMBER}}
|
|
EOF
|
|
|
|
cat >> build-metadata.tex <<'EOF'
|
|
\noindent\textbf{Manual version:} \ManualVersion\\
|
|
\textbf{Build identifier:} \BuildIdentifier\\
|
|
\textbf{Commit hash:} \BuildCommit\\
|
|
\textbf{Gitea Actions run:} \BuildRunNumber
|
|
EOF
|
|
|
|
- name: Record build identity and toolchain
|
|
run: |
|
|
SHORT_SHA="${GITHUB_SHA::7}"
|
|
echo "SHORT_SHA=${SHORT_SHA}" >> "$GITHUB_ENV"
|
|
echo "Commit: ${GITHUB_SHA} (${SHORT_SHA})"
|
|
echo "Run number: ${GITHUB_RUN_NUMBER}"
|
|
pdflatex --version | head -n 1
|
|
latexmk -v | head -n 2 | tail -n 1
|
|
python3 -c "import pygments; print('Pygments', pygments.__version__)"
|
|
|
|
- name: Compile the manual
|
|
working-directory: manual
|
|
# All options live in manual/.latexmkrc; it stops with a non-zero
|
|
# exit code on the first LaTeX error, which fails this step.
|
|
run: latexmk devopsAssignment.tex
|
|
|
|
- name: Verify the PDF exists
|
|
working-directory: manual
|
|
run: |
|
|
if [ ! -s devopsAssignment.pdf ]; then
|
|
echo "ERROR: manual/devopsAssignment.pdf is missing or empty"
|
|
exit 1
|
|
fi
|
|
ls -l devopsAssignment.pdf
|
|
|
|
- name: Upload the PDF as an artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: it-manual-build-${{ github.run_number }}-${{ env.SHORT_SHA }}
|
|
path: manual/devopsAssignment.pdf
|
|
if-no-files-found: error
|
|
retention-days: 30
|