Fix Prisma migrations hanging on Vercel (direct DB connection) #5
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: Run DB Migrations | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| migrate: | |
| name: Deploy migrations | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Wait for Vercel deployment | |
| uses: patrickedqvist/wait-for-vercel-preview@v1.3.2 | |
| id: wait-for-vercel | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| max_timeout: 300 | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} | |
| - name: Run migrations (production) | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| run: npm run db:migrate:deploy | |
| env: | |
| DATABASE_URL: ${{ secrets.PROD_DATABASE_URL }} | |
| - name: Run migrations (preview) | |
| if: github.event_name == 'pull_request' | |
| run: npm run db:migrate:deploy | |
| env: | |
| DATABASE_URL: ${{ secrets.PREVIEW_DATABASE_URL }} |