devops: setup deploy workflow #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}' |