mirror of
https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git
synced 2026-04-24 12:15:58 +00:00
Add deployment scripts and config
This commit is contained in:
44
scripts/sync-and-restart.sh
Normal file
44
scripts/sync-and-restart.sh
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Configuration
|
||||
APP_DIR="/var/www/Advanced-Smtp-Tester"
|
||||
LOG_FILE="/var/log/smtp-tester-sync.log"
|
||||
|
||||
# Navigate to app directory
|
||||
cd "$APP_DIR" || exit 1
|
||||
|
||||
# Log function
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Fetch latest changes
|
||||
git fetch origin
|
||||
|
||||
# Check if there are changes
|
||||
HEADHASH=$(git rev-parse HEAD)
|
||||
UPSTREAMHASH=$(git rev-parse origin/main)
|
||||
|
||||
if [ "$HEADHASH" != "$UPSTREAMHASH" ]; then
|
||||
log "Changes detected. Updating..."
|
||||
|
||||
# Pull changes
|
||||
git pull origin main >> "$LOG_FILE" 2>&1
|
||||
|
||||
# Check if package.json changed
|
||||
if git diff --name-only "$HEADHASH" "$UPSTREAMHASH" | grep "package.json"; then
|
||||
log "package.json changed. Installing dependencies..."
|
||||
npm install >> "$LOG_FILE" 2>&1
|
||||
fi
|
||||
|
||||
# Restart application
|
||||
log "Restarting application..."
|
||||
pm2 reload all >> "$LOG_FILE" 2>&1
|
||||
|
||||
log "Update complete."
|
||||
else
|
||||
# Uncomment next line for verbose logging of no-changes
|
||||
# log "No changes detected."
|
||||
# echo "No changes."
|
||||
:
|
||||
fi
|
||||
Reference in New Issue
Block a user