37 lines
1.0 KiB
Bash
37 lines
1.0 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# Auto-deploy script for LXC 139 (nginx proxy manager)
|
||
|
|
# Handles: landing/index.html
|
||
|
|
# 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) === LXC139 deploy triggered ==="
|
||
|
|
|
||
|
|
# Clone or pull
|
||
|
|
if [ ! -d "$REPO_DIR/.git" ]; then
|
||
|
|
git clone "$CLONE_URL" "$REPO_DIR"
|
||
|
|
CHANGED="landing/index.html"
|
||
|
|
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 '^landing/index.html'; then
|
||
|
|
echo "Deploying landing page..."
|
||
|
|
mkdir -p /var/www/matrix-landing
|
||
|
|
cp "$REPO_DIR/landing/index.html" /var/www/matrix-landing/index.html
|
||
|
|
nginx -s reload
|
||
|
|
echo "✓ landing page deployed and nginx reloaded"
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo "=== $(date) === LXC139 deploy complete ==="
|