From 51abb60b4db670a173d5baf013ec9a0b9369ae42 Mon Sep 17 00:00:00 2001 From: Ricardo Monla Date: Mon, 4 May 2026 08:25:30 -0300 Subject: [PATCH] Fix: deploy script con git -c safe.directory --- descargar-curso/deploy_ksaldis.sh | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/descargar-curso/deploy_ksaldis.sh b/descargar-curso/deploy_ksaldis.sh index 69a7b03..36b3223 100644 --- a/descargar-curso/deploy_ksaldis.sh +++ b/descargar-curso/deploy_ksaldis.sh @@ -1,29 +1,22 @@ #!/bin/bash -# deploy_ksaldis.sh — Deploy automático del libro de estudio -# Llamado por el webhook de Gitea al hacer push - set -e REPO_DIR="/var/www/ksaldis-dt/.repo" WEB_DIR="/var/www/ksaldis-dt" REPO_URL="http://10.0.10.205:3000/rmonla/rm-KSALDIS-DT.git" LOG="$WEB_DIR/deploy.log" - -# Configurar git safe.directory (necesario cuando el script corre como www-data) -export GIT_CONFIG_GLOBAL=/dev/null -git config --global --add safe.directory "$REPO_DIR" 2>/dev/null || true +GIT="git -c safe.directory=$REPO_DIR" log() { echo "$(date '+%Y-%m-%d %H:%M:%S') | $1" >> "$LOG" } -log "====== Deploy iniciado ======" +log "Deploy iniciado" -# Clonar o actualizar repo if [ -d "$REPO_DIR/.git" ]; then cd "$REPO_DIR" - git fetch origin 2>&1 - git reset --hard origin/main 2>&1 + $GIT fetch origin 2>&1 + $GIT reset --hard origin/main 2>&1 log "git pull OK" else rm -rf "$REPO_DIR" @@ -31,14 +24,13 @@ else log "git clone OK" fi -# Copiar LIBRO_DE_ESTUDIO.html como index.html SRC="$REPO_DIR/descargar-curso/descargas/LIBRO_DE_ESTUDIO.html" if [ -f "$SRC" ]; then cp "$SRC" "$WEB_DIR/index.html" log "index.html actualizado ($(wc -c < "$WEB_DIR/index.html") bytes)" fi -# Copiar secciones (sin videos_offline) +# Copiar secciones SECCIONES_SRC="$REPO_DIR/descargar-curso/descargas/secciones" if [ -d "$SECCIONES_SRC" ]; then rsync -a --delete "$SECCIONES_SRC/" "$WEB_DIR/secciones/" @@ -54,4 +46,4 @@ for asset in campus imagenes screenshots subpaginas; do fi done -log "====== Deploy completado ======" +log "Deploy completado"