name: Deploy Iddaai Frontend

on:
  push:
    branches: [main]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Kodu Cek
        uses: actions/checkout@v4

      - name: Docker Build
        run: |
          docker build \
            --build-arg NEXT_PUBLIC_API_URL='https://api.iddaai.com/api' \
            --build-arg NEXT_PUBLIC_AUTH_REQUIRED='false' \
            -t iddaai-fe:latest .

      - name: Eski Konteyneri Sil
        run: docker rm -f iddaai-fe || true

      - name: Yeni Versiyonu Baslat
        run: |
          docker run -d \
            --name iddaai-fe \
            --restart unless-stopped \
            --network iddaai_iddaai-network \
            -p 127.0.0.1:1510:3000 \
            -e NODE_ENV=production \
            -e NEXT_PUBLIC_API_URL='https://api.iddaai.com/api' \
            -e NEXTAUTH_URL='https://iddaai.com' \
            -e NEXTAUTH_SECRET='fFw34R134jRof1H2jofh2!32hU3gfjA1' \
            -e NEXT_PUBLIC_AUTH_REQUIRED='false' \
            iddaai-fe:latest
