Fix: deploy script con git -c safe.directory
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user