42 lines
1.2 KiB
Bash
42 lines
1.2 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Auto-deploy script for LXC 106 (cinny)
|
||
|
|
# Handles: cinny/config.json, cinny/dev-update.sh
|
||
|
|
# Triggered by: Gitea webhook on push to main
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
REPO_DIR="/opt/matrix-config"
|
||
|
|
LOG="/var/log/matrix-deploy.log"
|
||
|
|
CLONE_URL="https://code.lotusguild.org/LotusGuild/matrix.git"
|
||
|
|
|
||
|
|
exec >> "$LOG" 2>&1
|
||
|
|
echo "=== $(date) === LXC106 deploy triggered ==="
|
||
|
|
|
||
|
|
# Clone or pull
|
||
|
|
if [ ! -d "$REPO_DIR/.git" ]; then
|
||
|
|
git clone "$CLONE_URL" "$REPO_DIR"
|
||
|
|
CHANGED="cinny/config.json cinny/dev-update.sh"
|
||
|
|
else
|
||
|
|
cd "$REPO_DIR"
|
||
|
|
git fetch --all
|
||
|
|
PREV=$(git rev-parse HEAD)
|
||
|
|
git reset --hard origin/main
|
||
|
|
NEW=$(git rev-parse HEAD)
|
||
|
|
CHANGED=$(git diff --name-only "$PREV" "$NEW")
|
||
|
|
echo "Changed files: $CHANGED"
|
||
|
|
fi
|
||
|
|
|
||
|
|
if echo "$CHANGED" | grep -q '^cinny/config.json'; then
|
||
|
|
echo "Deploying cinny config.json..."
|
||
|
|
cp "$REPO_DIR/cinny/config.json" /var/www/html/config.json
|
||
|
|
echo "✓ config.json deployed"
|
||
|
|
fi
|
||
|
|
|
||
|
|
if echo "$CHANGED" | grep -q '^cinny/dev-update.sh'; then
|
||
|
|
echo "Deploying cinny dev-update.sh..."
|
||
|
|
cp "$REPO_DIR/cinny/dev-update.sh" /usr/local/bin/cinny-dev-update.sh
|
||
|
|
chmod +x /usr/local/bin/cinny-dev-update.sh
|
||
|
|
echo "✓ dev-update.sh deployed"
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "=== $(date) === LXC106 deploy complete ==="
|