57 lines
1.5 KiB
Bash
Executable File
57 lines
1.5 KiB
Bash
Executable File
#!/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." |