name: Local Build and Deploy on: push: branches: - main jobs: deploy: runs-on: shell steps: - name: Run Deploy Scripts Locally run: | set -e echo "--- EPIC WEB CONTROL: Starting Auto-Cleanup & Deploy ---" # 1. Clean up "dead" containers docker container prune -f || true # 2. Navigate to your website directory cd /var/www/atom-nexst/ # Fix ownership to ensure www-data owns the files before Git runs sudo chown -R www-data:www-data .git/ # 3. Fetch and update code using the local web user sudo -u www-data git fetch origin --prune sudo -u www-data git reset --hard origin/main # 4. Install dependencies, run migrations, and build the application /usr/local/bin/pnpm install --frozen-lockfile /usr/local/bin/pnpm db:migrate /usr/local/bin/pnpm prisma generate /usr/local/bin/pnpm build # 5. Restart the application service sudo systemctl restart atom-nexst.service echo "--- Deployment successfully completed ---"