feat(adoption): add admin approve and reject adoption endpoints #80
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| # ─────────────────────────────────────────────── | |
| # This workflow runs: | |
| # - On every Pull Request to main (for validation) | |
| # - On every push to main (for deploy) | |
| # ─────────────────────────────────────────────── | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| jobs: | |
| # ─────────────────────────────────────────────── | |
| # 1️⃣ TEST JOB | |
| # Runs unit + e2e tests inside CI environment | |
| # ─────────────────────────────────────────────── | |
| test: | |
| name: Run Tests | |
| runs-on: ubuntu-latest | |
| # ── Services required for your NestJS backend ── | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: petad | |
| POSTGRES_PASSWORD: petadpassword | |
| POSTGRES_DB: petad_db | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready -U petad" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| redis: | |
| image: redis:7 | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd="redis-cli ping" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| # ── Environment variables available to tests ── | |
| env: | |
| DATABASE_URL: postgresql://petad:petadpassword@localhost:5432/petad_db?schema=public | |
| REDIS_URL: redis://localhost:6379 | |
| JWT_SECRET: test-super-secret-jwt-key | |
| JWT_EXPIRATION: 7d | |
| PORT: 3000 | |
| NODE_ENV: test | |
| steps: | |
| # ── Checkout repository code ── | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # ── Setup Node 20 with npm cache ── | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| # ── Install dependencies using clean install ── | |
| - name: Install dependencies | |
| run: npm ci | |
| # ── Generate Prisma client ── | |
| - name: Generate Prisma Client | |
| run: npx prisma generate | |
| # ── Push schema to database (faster + safer for CI) | |
| # Using db push instead of migrate deploy prevents | |
| # failure if migrations are not committed properly. | |
| - name: Sync database schema | |
| run: npx prisma db push --force-reset | |
| # ── Run unit tests ── | |
| - name: Run unit tests | |
| run: npm test -- --passWithNoTests | |
| # ── Run e2e tests ── | |
| - name: Run e2e tests | |
| run: npm run test:e2e -- --passWithNoTests | |
| # ─────────────────────────────────────────────── | |
| # 2️⃣ BUILD JOB | |
| # Only runs if tests pass | |
| # Ensures project builds successfully | |
| # ─────────────────────────────────────────────── | |
| build: | |
| name: Build Check | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Generate Prisma Client | |
| run: npx prisma generate | |
| # ── Ensure project compiles (important for NestJS) ── | |
| - name: Build application | |
| run: npm run build | |
| # ── Upload compiled dist folder as artifact ── | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| retention-days: 1 | |
| # ─────────────────────────────────────────────── | |
| # 3️⃣ DEPLOY JOB | |
| # Runs ONLY when: | |
| # - push to main | |
| # - tests + build pass | |
| # ─────────────────────────────────────────────── | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Download build artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| # ─────────────────────────────────────────────── | |
| # 🔽 UNCOMMENT ONE DEPLOY OPTION BELOW 🔽 | |
| # ─────────────────────────────────────────────── | |
| # Option A: Railway | |
| # - name: Deploy to Railway | |
| # run: npx @railway/cli deploy | |
| # env: | |
| # RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} | |
| # Option B: Render Deploy Hook | |
| # - name: Deploy to Render | |
| # run: curl -X POST ${{ secrets.RENDER_DEPLOY_HOOK }} | |
| # Option C: Docker Hub | |
| # - name: Build and Push Docker Image | |
| # run: | | |
| # echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
| # docker build -t yourdockerhub/petad-backend:latest . | |
| # docker push yourdockerhub/petad-backend:latest | |
| - name: Deploy placeholder | |
| run: echo "✅ Tests passed and build succeeded. Configure deploy step above." | |