name: Deploy Next.js App on: push: branches: - main jobs: build-and-deploy: runs-on: selfhosted # of docker label, matcht met je runner labels steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: "npm" - name: Install dependencies run: npm ci - name: Build run: npm run build - name: Fix standalone output (static + public) run: | set -x ls -als .next/standalone cp -rv .next/static .next/standalone/.next/static cp -rv public .next/standalone/public ls -als .next/standalone/.next/static - name: Deploy standalone build run: | set -x rsync -av --delete .next/standalone/ /root/nodejsprojects/dcordabuse/ rsync -av /root/nodejsprojects/dcordabuse-src/.env /root/nodejsprojects/dcordabuse/ ls -als /root/nodejsprojects/dcordabuse/ ls -als /root/nodejsprojects/dcordabuse/.next/static - name: Restart app run: pm2 restart 0 - name: Notify Discord if: always() run: | STATUS="${{ job.status }}" if [ "$STATUS" = "success" ]; then COLOR=3066993 TITLE="✅ Deploy geslaagd" else COLOR=15158332 TITLE="❌ Deploy mislukt" fi curl -X POST "${{ secrets.DISCORD_WEBHOOK_URL }}" \ -H "Content-Type: application/json" \ -d "{ \"embeds\": [{ \"title\": \"$TITLE\", \"description\": \"DangerGuard — commit \`${{ gitea.sha }}\`\", \"color\": $COLOR }] }"