feat(webhook): scripts
This commit is contained in:
48
scripts/webhook-deploy/deploy-bruchtal.sh
Executable file
48
scripts/webhook-deploy/deploy-bruchtal.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
# test XDG_RUNTIME_DIR
|
||||
|
||||
LOGFILE="/var/log/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
|
||||
# -----------------------------
|
||||
log "Pulling latest changes from Gitea"
|
||||
git pull
|
||||
|
||||
# -----------------------------
|
||||
# 3️⃣ 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."
|
||||
25
scripts/webhook-deploy/deploy-bruchtal.sh-sik
Executable file
25
scripts/webhook-deploy/deploy-bruchtal.sh-sik
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
# test XDG_RUNTIME_DIR
|
||||
#HALLO
|
||||
cd /workspace
|
||||
|
||||
echo "==> Pulling latest changes"
|
||||
git pull
|
||||
|
||||
echo "==> Checking for new or modified Markdown files"
|
||||
# A = Added, M = Modified
|
||||
changed=$(git diff --name-status HEAD~1 HEAD | grep -E '^[AM]\s.*(\.md$|mkdocs\.yml$)' | awk '{print $2}' || true)
|
||||
|
||||
|
||||
if [ -n "$changed" ]; then
|
||||
echo "Markdown changes detected:"
|
||||
echo "$changed"
|
||||
echo "==> Restarting bruchtal-docs container"
|
||||
cd /workspace
|
||||
docker restart bruchtal-docs
|
||||
else
|
||||
echo "No Markdown changes detected. Skipping restart."
|
||||
fi
|
||||
|
||||
echo "==> Deploy finished"
|
||||
7
scripts/webhook-deploy/hooks.json
Normal file
7
scripts/webhook-deploy/hooks.json
Normal file
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": "bruchtal-deploy",
|
||||
"execute-command": "/workspace/deploy/deploy-bruchtal.sh",
|
||||
"command-working-directory": "/workspace"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user