Update CI

This commit is contained in:
Louis 2026-03-18 16:08:53 +01:00
parent 67175161b0
commit 1f3590715a

View file

@ -1,66 +1,71 @@
variables:
# https://hub.docker.com/r/alpine/git/tags
# Version de git utilisée
GIT_VERSION: v2.30.1
FILE_NAME: presentation
.git:push:
after_script:
# Go to the new directory
- cd "${CI_COMMIT_SHA}"
# Branche cible pour les PDF (modifiable via CI/CD variables)
PDF_BRANCH: "pdf"
- pwd
- ls
# Add all generated files to Git
- git add -f *.pdf
- git status
- |-
# Check if we have modifications to commit
CHANGES=$(git status --porcelain | wc -l)
if [ "$CHANGES" -gt "0" ]; then
# Show the status of files that are about to be created, updated or deleted
git status
# Commit all changes
git commit -m "${COMMIT_MESSAGE}"
# Update the repository and make sure to skip the pipeline create for this commit
git push origin "${CI_DEFAULT_BRANCH}" -o ci.skip
fi
before_script:
# Clone the repository via HTTPS inside a new directory
- git clone "https://${GITLAB_USERNAME}:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git" "${CI_COMMIT_SHA}"
# Set the displayed user with the commits that are about to be made
- git config --global user.email "${GIT_USER_EMAIL:-$GITLAB_USER_EMAIL}"
- git config --global user.name "${GIT_USER_NAME:-$GITLAB_USER_NAME}"
image:
entrypoint: [""]
name: alpine/git:${GIT_VERSION}
stage: deploy
FILE_NAMES: presentation
build_tex:
stage: build
image: registry.gitlab.com/islandoftex/images/texlive:latest
# rules:
# - changes:
# - "./*.tex"
# - "./**/*.tex"
image: danteev/texlive:latest # texlive plus inkscape and others
script:
- pdflatex --shell-escape $FILE_NAME.tex
- biber $FILE_NAME
- pdflatex --shell-escape $FILE_NAME.tex
- |
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:
- cat $FILE_NAME.log
- |
for FILE_NAME in $FILE_NAMES
do
echo "============================================"
cat ${FILE_NAME}.log
echo "============================================"
done
artifacts:
paths:
- $FILE_NAME.pdf
- "*.pdf"
deploy:
extends: .git:push
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é
- mv *.pdf "${CI_COMMIT_SHA}/"
- cd "${CI_COMMIT_SHA}"
# Crée une branche orpheline (vierge, sans historique ni fichiers)
- git checkout --orphan "${PDF_BRANCH}"
- git reset --hard
# 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