7f59b94dcf
Rebrand repository from "Re:Link" to "Startover" across the codebase. Updates include package names and scopes (@relink/* -> @startover/*), import paths, Next.js transpile settings, vitest name, UI text and docs, Dockerfile and CI/workflow names, deploy scripts and repo paths, and example/production env values. Also add auth-related env vars, an apps/web .env symlink, and small formatting/typing cleanups in several TSX/TS files and tests to accommodate the rename.
84 lines
2.1 KiB
Bash
84 lines
2.1 KiB
Bash
#!/bin/bash
|
|
# ===========================================
|
|
# Startover Poll-based Auto Deploy
|
|
# Checks Gitea for new commits every minute
|
|
# ===========================================
|
|
|
|
APP_DIR="$HOME/startover"
|
|
REPO_DIR="$APP_DIR/repo"
|
|
LOG_FILE="$APP_DIR/deploy.log"
|
|
LOCK_FILE="$APP_DIR/deploy.lock"
|
|
GITEA_REPO="http://39.117.244.52:3000/geonhee/startover.git"
|
|
BRANCH="main"
|
|
|
|
log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" >> "$LOG_FILE"; }
|
|
|
|
# Prevent concurrent deploys
|
|
if [ -f "$LOCK_FILE" ]; then
|
|
LOCK_PID=$(cat "$LOCK_FILE" 2>/dev/null)
|
|
if kill -0 "$LOCK_PID" 2>/dev/null; then
|
|
exit 0
|
|
fi
|
|
rm -f "$LOCK_FILE"
|
|
fi
|
|
|
|
# First time: clone
|
|
if [ ! -d "$REPO_DIR/.git" ]; then
|
|
log "Initial clone..."
|
|
echo $$ > "$LOCK_FILE"
|
|
trap 'rm -f "$LOCK_FILE"' EXIT
|
|
git clone "$GITEA_REPO" "$REPO_DIR"
|
|
cd "$REPO_DIR"
|
|
|
|
if [ -f "$APP_DIR/.env.production" ]; then
|
|
cp "$APP_DIR/.env.production" "$REPO_DIR/.env.production"
|
|
fi
|
|
|
|
log "Building and deploying (first time)..."
|
|
docker compose -f docker-compose.prod.yml --env-file .env.production up -d --build --remove-orphans >> "$LOG_FILE" 2>&1
|
|
docker image prune -f >> "$LOG_FILE" 2>&1
|
|
log "First deploy completed. Commit: $(git log --oneline -1)"
|
|
exit 0
|
|
fi
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
# Fetch latest
|
|
git fetch origin "$BRANCH" --quiet 2>/dev/null
|
|
|
|
LOCAL=$(git rev-parse HEAD)
|
|
REMOTE=$(git rev-parse origin/$BRANCH)
|
|
|
|
# No changes
|
|
if [ "$LOCAL" = "$REMOTE" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
# New commits detected - deploy
|
|
echo $$ > "$LOCK_FILE"
|
|
trap 'rm -f "$LOCK_FILE"' EXIT
|
|
|
|
log "=== New commits detected ==="
|
|
log "Local: $LOCAL"
|
|
log "Remote: $REMOTE"
|
|
|
|
git reset --hard origin/$BRANCH
|
|
log "Updated to: $(git log --oneline -1)"
|
|
|
|
if [ -f "$APP_DIR/.env.production" ]; then
|
|
cp "$APP_DIR/.env.production" "$REPO_DIR/.env.production"
|
|
fi
|
|
|
|
log "Building and deploying..."
|
|
docker compose -f docker-compose.prod.yml --env-file .env.production up -d --build --remove-orphans >> "$LOG_FILE" 2>&1
|
|
|
|
sleep 15
|
|
if curl -sf http://localhost/health > /dev/null 2>&1; then
|
|
log "Health check PASSED"
|
|
else
|
|
log "WARNING: Health check pending"
|
|
fi
|
|
|
|
docker image prune -f >> "$LOG_FILE" 2>&1
|
|
log "=== Deploy completed ==="
|