Skip to content

Commit

Permalink
devops: setup deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuldahal committed May 31, 2024
1 parent 1322b46 commit 2c1d761
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy to Render

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Check if schema.prisma has changed
id: schema_changed
run: |
git fetch origin main
git diff --exit-code origin/main -- prisma/schema.prisma || echo "schema_changed=true" >> $GITHUB_ENV
- name: Generate Prisma client
if: env.schema_changed == 'true'
run: npx prisma generate

- name: Create and apply Prisma migrations
if: env.schema_changed == 'true'
run: |
npx prisma migrate dev --name auto-migration
npx prisma migrate deploy
- name: Build the application
run: yarn build

- name: Deploy to Render
env:
RENDER_API_KEY: ${{ secrets.RENDER_API_KEY }}
SERVICE_ID: ${{ secrets.RENDER_SERVICE_ID }}
run: |
curl -X POST "https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys" \
-H "Authorization: Bearer ${{ secrets.RENDER_API_KEY }}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
--data '{"clearCache":false}'

0 comments on commit 2c1d761

Please sign in to comment.