name: Remote Build and Deploy on: push: branches: - main concurrency: group: atomcms-production-deploy cancel-in-progress: false jobs: deploy: runs-on: shell steps: - name: Check out pushed commit uses: actions/checkout@v4 with: fetch-depth: 1 - name: Deploy AtomCMS shell: bash run: | set -Eeuo pipefail readonly APP_DIR="/var/www/atom-nexst" readonly SOURCE_DIR="${GITHUB_WORKSPACE}" echo "--- Starting EPIC WEB CONTROL Deployment ---" test -n "$SOURCE_DIR" test -d "$SOURCE_DIR/src" test -f "$SOURCE_DIR/package.json" test -f "$SOURCE_DIR/pnpm-lock.yaml" test -d "$APP_DIR" test -f "$APP_DIR/.env" test "$APP_DIR" = "/var/www/atom-nexst" echo "--- Synchronizing Application Files ---" sudo rsync -a --delete \ --exclude=".git/" \ --exclude=".env" \ --exclude=".next/" \ --exclude="node_modules/" \ --exclude="storage/" \ --exclude="docs/" \ "$SOURCE_DIR/" "$APP_DIR/" cd "$APP_DIR" test "$PWD" = "$APP_DIR" echo "--- Preparing pnpm ---" sudo corepack enable sudo corepack prepare pnpm@10.33.4 --activate echo "--- Installing Locked Dependencies ---" sudo pnpm install --frozen-lockfile --prod=false echo "--- Generating Prisma Client ---" sudo pnpm prisma:generate echo "--- Running Database Migrations ---" sudo pnpm db:migrate echo "--- Building Application ---" sudo rm -rf -- "$APP_DIR/.next" sudo pnpm build echo "--- Restarting Atom Nexst Service ---" sudo systemctl restart atom-nexst.service sudo systemctl is-active --quiet atom-nexst.service echo "--- Verifying Deployed Revision ---" echo "DEPLOYED_COMMIT=${GITHUB_SHA}" echo "--- Deployment Completed Successfully ---"