feat: Add database seeding step to CI workflow #24
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 | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: pnpm/action-setup@v2 | |
| with: | |
| version: 8 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - run: pnpm install | |
| - run: npx prisma db push | |
| - name: Seed database if empty | |
| run: | | |
| # Only seed if no projects exist | |
| PROJECT_COUNT=$(npx prisma db execute --stdin <<< 'SELECT COUNT(*) as count FROM Project;' --url="$DATABASE_URL" | grep -o '[0-9]*' | tail -1) | |
| if [ "$PROJECT_COUNT" = "0" ]; then | |
| echo "Database is empty, seeding..." | |
| pnpm db:seed | |
| else | |
| echo "Database already has $PROJECT_COUNT projects, skipping seed" | |
| fi | |
| - run: pnpm run lint | |
| - run: pnpm run build | |
| - run: pnpm run test |