Update .gitea/workflows/deploy.yaml
Local Build and Deploy / deploy (push) Successful in 48s

This commit is contained in:
remco committed 2026-07-18 15:49:11 +02:00
1 parent dc627cf1db
commit c73f41dc70
1 file changed
+7 -21
+7 -21
View File
@@ -11,71 +11,57 @@ jobs:
run: |
set -e
# 1. Lockfile to prevent concurrent, duplicate deployments
# 1. Deployment lock & init
exec 9>/var/tmp/epic_web_control_deploy.lock
flock -n 9 || { echo "ERROR: Another deployment is already running! Cancelling."; exit 1; }
echo "--- EPIC WEB CONTROL: Starting Auto-Cleanup & Deploy ---"
# Fallback routine on deployment crashes
error_handler() {
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
echo "Attempting to keep the current service running..." >&2
sudo systemctl restart atom-nexst.service || true
exit 1
}
trap 'error_handler $LINENO' ERR
# 2. Clean up old system Docker images safely
# 2. Cleanup & Git Sync
docker image prune -f
# 3. Git updates & Permissions configuration
cd /var/www/atom-nexst/
git config --global --add safe.directory /var/www/atom-nexst
git remote set-url origin /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git/
git fetch origin --prune
git reset --hard origin/main
# Clean untracked files while preserving environment configurations and the Next.js cache (.next/cache)
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next
# Clear old build artifacts but KEEP the cache directory inside .next
# Verwijder oude builds, behoud de cache voor snelheid
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
# 4. Install dependencies with modern PNPM security rules
# PRISMA_SKIP_POSTINSTALL_GENERATE avoids running duplicate prisma client builds
# 3. Dependencies & Database
export PNPM_CONFIG_ONLY_BUILT_DEPENDENCIES="@parcel/watcher,@swc/core,sharp"
export PRISMA_SKIP_POSTINSTALL_GENERATE=1
pnpm install --frozen-lockfile
# 5. Database migrations & Generate Prisma Client
pnpm db:migrate
pnpm prisma:generate
# 6. Next.js Build (Standalone Mode for Next.js 16 + Turbopack)
# SKIP_ENV_VALIDATION=true prevents Zod from crashing on database URL formatting characters (like %40) during build time
# 4. Standalone Next.js Build
export NEXT_DISABLE_SOURCEMAPS=1
export NEXT_TELEMETRY_DISABLED=1
export UV_THREADPOOL_SIZE=2
export SKIP_ENV_VALIDATION=true
pnpm build
# 6b. Configure Standalone Bundle Paths
# 5. Sync Standalone Bundle
echo "Preparing standalone bundle paths..."
# Copy open assets, media, and static CSS/JS to the standalone bundle path
cp -r public .next/standalone/
cp -r .next/static .next/standalone/.next/
# Copy the core Prisma directory to the standalone node_modules to ensure database actions work
cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true
# Explicitly sync your live configuration environment file into the standalone folder
cp .env .next/standalone/.env
# 7. Correct file ownership and permissions for the www-data web server user
# 6. Permissions & Restart
sudo chown -R www-data:www-data /var/www/atom-nexst/
sudo chmod -R g+rw /var/www/atom-nexst/
# 8. Restart the Systemd service gracefully (Fast reloads with node server.js)
echo "Restarting systemd service gracefully..."
sudo systemctl restart atom-nexst.service