Update production pipeline
This commit is contained in:
39
.github/workflows/prod-pipeline.yml
vendored
39
.github/workflows/prod-pipeline.yml
vendored
@@ -5,8 +5,33 @@ on:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
check-migrations:
|
||||
name: Check for new Prisma migrations
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
has_new_migrations: ${{ steps.diff.outputs.has_new_migrations }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0 # get full history so git diff works properly
|
||||
|
||||
- name: Detect new migration files
|
||||
id: diff
|
||||
run: |
|
||||
# Compare the last two commits on main
|
||||
if git diff --quiet HEAD~1 -- prisma/migrations/; then
|
||||
echo "✅ No new Prisma migrations detected."
|
||||
echo "has_new_migrations=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "⚠️ New Prisma migrations detected! Blocking deployment."
|
||||
echo "has_new_migrations=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
deploy:
|
||||
name: Deploy to production
|
||||
runs-on: ubuntu-latest
|
||||
needs: check-migrations
|
||||
if: needs.check-migrations.outputs.has_new_migrations == 'false'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Bun
|
||||
@@ -29,3 +54,15 @@ jobs:
|
||||
git pull origin main
|
||||
git status
|
||||
make prod
|
||||
|
||||
block-deploy:
|
||||
name: Block deployment (new migrations detected)
|
||||
runs-on: ubuntu-latest
|
||||
needs: check-migrations
|
||||
if: needs.check-migrations.outputs.has_new_migrations == 'true'
|
||||
steps:
|
||||
- name: Stop deploy
|
||||
run: |
|
||||
echo "🚫 Deployment blocked because new Prisma migrations were detected."
|
||||
echo "Please apply migrations on staging and verify before deploying to production."
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user