Skip to content

fix: remove ignoreBuildErrors from next.config.ts #192

fix: remove ignoreBuildErrors from next.config.ts

fix: remove ignoreBuildErrors from next.config.ts #192

name: Check Prisma Migrations
permissions:
contents: read
on:
pull_request:
env:
NEON_PROJECT_ID: ${{ vars.NEON_PROJECT_ID }}
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
# Main branch ID from Neon console (e.g., br-lively-thunder-28239235)
NEON_MAIN_BRANCH_ID: ${{ vars.NEON_MAIN_BRANCH_ID }}
jobs:
# Check if migration files changed
changes:
name: Check for Changes
runs-on: ubuntu-latest
outputs:
migrations: ${{ steps.filter.outputs.migrations }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
migrations:
- 'packages/data/schema.prisma'
- 'packages/data/migrations/**'
check:
name: Validate Migrations
needs: changes
if: needs.changes.outputs.migrations == 'true'
runs-on: ubuntu-latest
env:
# Dummy values for env validation during install/generate (not used for actual DB operations)
DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy"
EMAIL_FROM: "ci@example.com"
AUTH_SECRET: "ci-dummy-secret-not-used"
PROPSTO_ENV: "production"
PROPSTO_APP_URL: "https://app.example.com"
AUTH_URL: "https://auth.example.com"
PROPSTO_HOST: "example.com"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Validate schema syntax
run: pnpm --filter @propsto/data lint
dry-run:
name: Dry-run Migration on Production Copy
needs: changes
if: needs.changes.outputs.migrations == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
env:
# Dummy values for env validation during install/generate (overridden later for actual migration)
DATABASE_URL: "postgresql://dummy:dummy@localhost:5432/dummy"
EMAIL_FROM: "ci@example.com"
AUTH_SECRET: "ci-dummy-secret-not-used"
PROPSTO_ENV: "production"
PROPSTO_APP_URL: "https://app.example.com"
AUTH_URL: "https://auth.example.com"
PROPSTO_HOST: "example.com"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "pnpm"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create Neon branch from production
id: create-branch
run: |
BRANCH_NAME="migration-check-pr-${{ github.event.pull_request.number }}-$(date +%s)"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
# Create branch from main (production)
RESPONSE=$(curl -s -X POST \
"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID/branches" \
-H "Authorization: Bearer $NEON_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"branch\": {
\"name\": \"$BRANCH_NAME\",
\"parent_id\": \"$NEON_MAIN_BRANCH_ID\"
},
\"endpoints\": [{
\"type\": \"read_write\"
}]
}")
echo "API Response: $RESPONSE"
BRANCH_ID=$(echo $RESPONSE | jq -r '.branch.id')
if [ "$BRANCH_ID" == "null" ] || [ -z "$BRANCH_ID" ]; then
echo "::error::Failed to create Neon branch"
echo $RESPONSE
exit 1
fi
echo "branch_id=$BRANCH_ID" >> $GITHUB_OUTPUT
# Get the connection string
ENDPOINT_ID=$(echo $RESPONSE | jq -r '.endpoints[0].id')
HOST=$(echo $RESPONSE | jq -r '.endpoints[0].host')
# Get connection URI (need to fetch separately with password)
CONN_RESPONSE=$(curl -s -X GET \
"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID/connection_uri?branch_id=$BRANCH_ID&endpoint_id=$ENDPOINT_ID&database_name=${{ vars.NEON_DATABASE_NAME }}&role_name=${{ vars.NEON_ROLE_NAME }}" \
-H "Authorization: Bearer $NEON_API_KEY")
CONNECTION_URI=$(echo $CONN_RESPONSE | jq -r '.uri')
echo "::add-mask::$CONNECTION_URI"
echo "connection_uri=$CONNECTION_URI" >> $GITHUB_OUTPUT
- name: Run migration dry-run
id: migrate
env:
DATABASE_URL: ${{ steps.create-branch.outputs.connection_uri }}
run: |
echo "Running migrations on temporary Neon branch..."
pnpm --filter @propsto/data db-deploy
- name: Delete Neon branch
if: always()
run: |
BRANCH_ID="${{ steps.create-branch.outputs.branch_id }}"
if [ -n "$BRANCH_ID" ] && [ "$BRANCH_ID" != "null" ]; then
echo "Cleaning up Neon branch: $BRANCH_ID"
curl -s -X DELETE \
"https://console.neon.tech/api/v2/projects/$NEON_PROJECT_ID/branches/$BRANCH_ID" \
-H "Authorization: Bearer $NEON_API_KEY"
echo "Branch deleted"
fi
- name: Report migration failure
if: failure() && steps.migrate.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `❌ **Migration dry-run failed!**\n\nThe migrations in this PR failed when applied to a copy of the production database.\n\nPlease check the migration files and ensure they are compatible with the current production schema.\n\n[View workflow logs](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`
});