presentation-colbisbm/.gitlab-ci.yml
2026-03-18 16:41:17 +01:00

72 lines
1.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

variables:
# Version de git utilisée
GIT_VERSION: v2.30.1
# Branche cible pour les PDF (modifiable via CI/CD variables)
PDF_BRANCH: "pdf"
FILE_NAMES: presentation
build_tex:
stage: build
image: danteev/texlive:latest # texlive plus inkscape and others
script:
- |
for FILE_NAME in $FILE_NAMES
do
echo "Compiling ${FILE_NAME}"
pdflatex --shell-escape ${FILE_NAME}.tex
if test -f ${FILE_NAME}.bcf; then
echo "Found ${FILE_NAME}.bcf, running biber"
biber ${FILE_NAME}
fi
pdflatex --shell-escape ${FILE_NAME}.tex
done
after_script:
- |
for FILE_NAME in $FILE_NAMES
do
echo "============================================"
cat ${FILE_NAME}.log
echo "============================================"
done
artifacts:
paths:
- "*.pdf"
deploy:
stage: deploy
image:
name: alpine/git:${GIT_VERSION}
entrypoint: [""]
before_script:
# Clone le repo dans un dossier temporaire
- git clone "https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${CI_COMMIT_SHA}"
# Configure lidentité git
- git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"
- git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"
script:
# Déplace les PDFs compilés dans le repo cloné
- cd "${CI_COMMIT_SHA}"
# Crée une branche orpheline (vierge, sans historique ni fichiers)
- git checkout --orphan "${PDF_BRANCH}"
- git reset --hard
- mv ../*.pdf ./
# Ajoute uniquement les PDF
- git add -f *.pdf
# Vérifie sil y a des changements et push
- |
CHANGES=$(git status --porcelain | wc -l)
if [ "$CHANGES" -gt "0" ]; then
git commit -m "${COMMIT_MESSAGE:-Updating PDF files}"
git push --force origin "${PDF_BRANCH}" -o ci.skip
else
echo "No PDF changes to commit"
fi