🚀 Setup automated deployment system with comprehensive credential protection

- Added Express server with Git info API endpoint
- Created automated deployment scripts (systemd-based, not PM2)
- Implemented 5-minute auto-sync with GitHub
- Enhanced .gitignore with 200+ credential protection patterns
- Added Git version badge to UI footer
- Created comprehensive deployment documentation
- Added TurnKey Nginx fix for default control panel issue
- Included security verification tools

All credentials protected and verified safe for deployment.
This commit is contained in:
2025-12-27 21:34:08 +11:00
parent b4bddb2aa0
commit d7f534284a
22 changed files with 3540 additions and 0 deletions

65
auto-sync.sh Normal file
View File

@@ -0,0 +1,65 @@
#!/bin/bash
# ============================================================================
# Auto-Sync Script - Run by Cron Every 5 Minutes
# ============================================================================
# This script:
# 1. Checks for changes in Git repository
# 2. Pulls updates if available
# 3. Restarts the service ONLY if changes were detected
# ============================================================================
set -e
APP_NAME="web-page-performance-test"
APP_DIR="/var/www/$APP_NAME"
LOG_FILE="/var/log/$APP_NAME-autosync.log"
# Function to log with timestamp
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
log "========================================="
log "Starting auto-sync check..."
cd "$APP_DIR" || exit 1
# Fetch latest from remote
git fetch origin main 2>&1 | tee -a "$LOG_FILE"
# Check if local is behind remote
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main)
if [ "$LOCAL" = "$REMOTE" ]; then
log "✅ Already up to date. No changes detected."
exit 0
fi
log "🔄 Changes detected! Pulling updates..."
# Pull changes
git pull origin main 2>&1 | tee -a "$LOG_FILE"
# Install/update dependencies if package.json changed
if git diff --name-only $LOCAL $REMOTE | grep -q "package.json"; then
log "📦 package.json changed. Running npm install..."
npm install 2>&1 | tee -a "$LOG_FILE"
fi
# Restart the service
log "🔄 Restarting $APP_NAME service..."
systemctl restart "$APP_NAME" 2>&1 | tee -a "$LOG_FILE"
# Wait a moment and check status
sleep 2
if systemctl is-active --quiet "$APP_NAME"; then
log "✅ Service restarted successfully!"
else
log "❌ WARNING: Service may have failed to start!"
systemctl status "$APP_NAME" --no-pager 2>&1 | tee -a "$LOG_FILE"
fi
log "✅ Auto-sync completed!"
log "========================================="