Skip to content

Instantly share code, notes, and snippets.

@a7ul
Created August 3, 2023 17:24
Show Gist options
  • Save a7ul/c3423fa6b446997c8621f6a6a77114c0 to your computer and use it in GitHub Desktop.
Save a7ul/c3423fa6b446997c8621f6a6a77114c0 to your computer and use it in GitHub Desktop.
Check if you forgot to create migration in prisma after schema change in Github actions PR
name: Run PR checks
on:
pull_request:
branches:
- "main"
jobs:
checks:
name: Run checks
runs-on: ubuntu-latest
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 5s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
permissions:
contents: "read"
id-token: "write"
steps:
- name: Checkout repo
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: "yarn"
cache-dependency-path: "./api/yarn.lock"
node-version: "18.x"
- name: Install deps
working-directory: ./api
run: yarn
- name: Check if prisma migration is updated
working-directory: ./api
run: |-
npx prisma migrate diff --exit-code \
--from-migrations ./prisma/migrations \
--to-schema-datamodel ./prisma/schema.prisma \
--shadow-database-url ${{env.DATABASE_URL}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment