Files
EpicNext-Cms/.gitea/workflows/deploy.yaml
T
remco c73f41dc70
Local Build and Deploy / deploy (push) Successful in 48s
Update .gitea/workflows/deploy.yaml
2026-07-18 15:49:11 +02:00

74 lines
2.7 KiB
YAML

name: Local Build and Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: shell
steps:
- name: Run Deploy Scripts Locally
run: |
set -e
# 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 ---"
error_handler() {
echo "!!! DEPLOYMENT FAILED on line $1 !!!" >&2
sudo systemctl restart atom-nexst.service || true
exit 1
}
trap 'error_handler $LINENO' ERR
# 2. Cleanup & Git Sync
docker image prune -f
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
git clean -fd -e .env -e .env.local -e .env.production -e .env*.local -e .next
# Verwijder oude builds, behoud de cache voor snelheid
find .next -mindepth 1 -maxdepth 1 ! -name 'cache' -exec rm -rf {} + 2>/dev/null || true
# 3. Dependencies & Database
export PNPM_CONFIG_ONLY_BUILT_DEPENDENCIES="@parcel/watcher,@swc/core,sharp"
export PRISMA_SKIP_POSTINSTALL_GENERATE=1
pnpm install --frozen-lockfile
pnpm db:migrate
pnpm prisma:generate
# 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
# 5. Sync Standalone Bundle
echo "Preparing standalone bundle paths..."
cp -r public .next/standalone/
cp -r .next/static .next/standalone/.next/
cp -r node_modules/@prisma .next/standalone/node_modules/ 2>/dev/null || true
cp .env .next/standalone/.env
# 6. Permissions & Restart
sudo chown -R www-data:www-data /var/www/atom-nexst/
sudo chmod -R g+rw /var/www/atom-nexst/
echo "Restarting systemd service gracefully..."
sudo systemctl restart atom-nexst.service
sleep 2
if ! systemctl is-active --quiet atom-nexst.service; then
echo "ERROR: atom-nexst.service failed to start!" >&2
exit 1
fi
echo "--- Deployment successfully completed ---"