Files
Bruchtal/scripts/webhook-deploy/deploy-bruchtal.sh
2026-03-12 22:14:14 +01:00

57 lines
1.5 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
set -e
# test XDG_RUNTIME_DIR
LOGFILE="/srv/docker/repo/scripts/bruchtal-deploy.log"
cd /workspace
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') | $*" | tee -a "$LOGFILE"
}
# -----------------------------
# 1⃣ VM-Repo sauber halten
# -----------------------------
log "Checking for local changes on VM..."
if [ -n "$(git status --porcelain)" ]; then
log "⚠️ Warning: Local changes on VM will be lost!"
git reset --hard
git clean -fd
log "Local changes discarded."
else
log "VM repo is clean, no local changes to discard."
fi
# -----------------------------
# 2⃣ Pull latest changes
# -----------------------------
# safe directory for git in CI environment
git config --global --add safe.directory /workspace
log "Pulling latest changes from Gitea"
git pull
# -----------------------------
# 3⃣ Redeploy changed containers
# -----------------------------
#/srv/docker/scripts/redeploy-containers.sh
# -----------------------------
# 4⃣ Check for Markdown changes
# -----------------------------
log "Checking for new or modified Markdown files..."
changed=$(git diff --name-status HEAD~1 HEAD | grep -E '^[AM]\s.*(\.md$|mkdocs\.yml$)' | awk '{print $2}' || true)
if [ -n "$changed" ]; then
log "Markdown changes detected:"
for f in $changed; do
log " - $f"
done
log "Restarting bruchtal-docs container..."
docker restart bruchtal-docs
else
log "No Markdown changes detected. Skipping restart."
fi
log "Deploy finished."