Files
rm-KSALDIS-DT/_hist/deploy_ksaldis.sh
T

43 lines
1.0 KiB
Bash

#!/bin/bash
# deploy_ksaldis.sh — Script de deploy automático
# Llamado por el webhook de Gitea al hacer push
#
# Clona/actualiza el repo y copia LIBRO_DE_ESTUDIO.html como index.html
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"
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') | $1" >> "$LOG"
}
log "Deploy iniciado"
# Clonar o actualizar repo
GIT="git -c safe.directory=$REPO_DIR"
if [ -d "$REPO_DIR/.git" ]; then
cd "$REPO_DIR"
$GIT fetch origin 2>&1
$GIT reset --hard origin/main 2>&1
log "git pull OK"
else
git clone "$REPO_URL" "$REPO_DIR" 2>&1
log "git clone OK"
fi
# Copiar el libro 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)"
else
log "ERROR: LIBRO_DE_ESTUDIO.html no encontrado en el repo"
exit 1
fi
log "Deploy completado"