From ed871ece7bc5cd5e0964fb20617942c2938d053e Mon Sep 17 00:00:00 2001 From: WhyAsh5114 Date: Mon, 17 Jun 2024 22:31:19 +0530 Subject: [PATCH] updated workflow --- .github/workflows/main-workflow.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main-workflow.yml b/.github/workflows/main-workflow.yml index a81ded75..aaa2590f 100644 --- a/.github/workflows/main-workflow.yml +++ b/.github/workflows/main-workflow.yml @@ -7,8 +7,6 @@ env: on: push: - paths: - - './prisma/migrations/**' branches: - main - master @@ -51,7 +49,7 @@ jobs: name: Deploy runs-on: ubuntu-latest needs: test - if: ${{ github.event_name == 'push' && needs.test.result == 'success' }} + if: ${{ needs.test.result == 'success' }} steps: - name: Checkout repo uses: actions/checkout@v3 @@ -59,7 +57,18 @@ jobs: uses: actions/setup-node@v3 - name: Install dependencies run: npm install + - name: Check for changes in migrations + id: check_migrations + run: | + git fetch origin ${{ github.sha }} + if git diff --quiet HEAD~1 HEAD -- ./prisma/migrations; then + echo "No changes in migrations" + exit 1 + else + echo "Changes detected in migrations" + fi - name: Apply all pending migrations to the database + if: steps.check_migrations.outcome == 'success' run: npx prisma migrate deploy env: DATABASE_URL: ${{ secrets.DATABASE_URL_MAIN }}