ci/cd setup #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: Backend Deployment | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'backend/**' | |
pull_request: | |
jobs: | |
ci: | |
name: Continuous Integration | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "npm" | |
- name: Install dependencies | |
run: npm install | |
- name: Run linting | |
run: npm run lint --if-present | |
- name: Generate Prisma client | |
run: npx prisma generate --no-engine | |
cd: | |
name: Continuous Deployment | |
needs: ci # Deploy only if CI passes | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "npm" | |
- name: Install dependencies | |
run: npm install | |
- name: Apply Prisma Migrations | |
run: npx prisma migrate deploy | |
env: | |
DATABASE_URL: ${{ secrets.MAIN_DATABASE_URL }} # Uses the main Neon DB | |
- name: Generate Prisma Client | |
run: npx prisma generate --no-engine | |
env: | |
DATABASE_URL: ${{ secrets.ACCELERATE_DATABASE_URL }} # Uses Accelerate DB for Workers | |
- name: Deploy to Cloudflare Workers | |
run: npm run deploy | |
env: | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |