feat(webhook): redeploy
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /docker/Bruchtal/compose
|
||||
|
||||
for d in */; do
|
||||
echo "Deploying $d"
|
||||
(cd "$d" && docker compose up -d)
|
||||
done
|
||||
60
scripts/redeploy-containers.sh
Normal file
60
scripts/redeploy-containers.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Auto-update Docker-Compose stacks nach Git-Pull
|
||||
# Läuft als dockeradmin, prüft geänderte Compose-Dateien
|
||||
# Stillgelegte Container werden ignoriert
|
||||
|
||||
REPO_DIR="/srv/docker"
|
||||
LOGFILE="/var/log/docker-update.log"
|
||||
|
||||
INACTIVE_CONTAINERS=("adguard" "kea" "caddy" "wikijs")
|
||||
|
||||
log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') | $*" | tee -a "$LOGFILE"
|
||||
}
|
||||
|
||||
log "===== Starting Auto-Update (changed Compose only) ====="
|
||||
|
||||
cd "$REPO_DIR" || { log "ERROR: Cannot enter $REPO_DIR"; exit 1; }
|
||||
|
||||
# 1️⃣ Pull neueste Änderungen
|
||||
git fetch --all &>/dev/null
|
||||
git reset --hard origin/main &>/dev/null
|
||||
log "Pulled latest changes from Git."
|
||||
|
||||
# 2️⃣ Geänderte Compose-Dateien ermitteln
|
||||
CHANGED=$(git diff --name-only HEAD~1 HEAD | grep -E '^compose/.+/docker-compose\.yml$' || true)
|
||||
|
||||
if [ -z "$CHANGED" ]; then
|
||||
log "No Compose files changed. Nothing to update."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 3️⃣ Nur geänderte Container updaten
|
||||
for FILE in $CHANGED; do
|
||||
CONTAINER_NAME=$(echo "$FILE" | cut -d'/' -f2)
|
||||
|
||||
# Inaktive Container überspringen
|
||||
if [[ " ${INACTIVE_CONTAINERS[@]} " =~ " ${CONTAINER_NAME} " ]]; then
|
||||
log "Skipping inactive container: $CONTAINER_NAME"
|
||||
continue
|
||||
fi
|
||||
|
||||
COMPOSE_DIR="$REPO_DIR/compose/$CONTAINER_NAME"
|
||||
if [ ! -d "$COMPOSE_DIR" ]; then
|
||||
log "Warning: $COMPOSE_DIR does not exist, skipping..."
|
||||
continue
|
||||
fi
|
||||
|
||||
log "Updating container: $CONTAINER_NAME"
|
||||
cd "$COMPOSE_DIR" || continue
|
||||
docker compose pull &>/dev/null
|
||||
docker compose up -d &>/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "✅ $CONTAINER_NAME updated successfully"
|
||||
else
|
||||
log "❌ Failed to update $CONTAINER_NAME"
|
||||
fi
|
||||
done
|
||||
|
||||
log "===== Auto-Update Completed ====="
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /docker/Bruchtal/compose
|
||||
|
||||
for d in */; do
|
||||
echo "Updating $d"
|
||||
(cd "$d" && docker compose pull && docker compose up -d)
|
||||
done
|
||||
@@ -29,7 +29,13 @@ log "Pulling latest changes from Gitea"
|
||||
git pull
|
||||
|
||||
# -----------------------------
|
||||
# 3️⃣ Check for Markdown changes
|
||||
# 3️⃣ Redeploy changed containers
|
||||
# -----------------------------
|
||||
#/srv/docker/scripts/deploy-changed-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)
|
||||
|
||||
Reference in New Issue
Block a user