Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: FarmSmart CI/CD Pipeline

# Trigger the workflow on pushes and pull requests to the main branch
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Define environment variables if needed
env:
NODE_VERSION: '18.x'

jobs:
# ------------------------------------------------------------------
# JOB 1: BACKEND CI (Test & Build)
# ------------------------------------------------------------------
backend-ci:
name: Backend CI (Test & Build)
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json

- name: Install Dependencies
run: npm ci

- name: Run Tests (Jest)
run: npm test -- --passWithNoTests

- name: Build / Type Check (TypeScript)
run: npm run build

# ------------------------------------------------------------------
# JOB 2: FRONTEND CI (Lint & Build)
# ------------------------------------------------------------------
frontend-ci:
name: Frontend CI (Lint & Build)
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./frontend

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install Dependencies
run: npm ci

- name: Lint Code (ESLint)
# Only run lint if the script exists
run: npm run lint --if-present

- name: Build Project (Vite)
run: npm run build

# ------------------------------------------------------------------
# JOB 3: DEPLOY TO RENDER (CD)
# ------------------------------------------------------------------
deploy:
name: Deploy to Render
needs: [backend-ci, frontend-ci] # Only deploy if CI passes
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest

steps:
- name: Trigger Render Deploy (Backend)
if: env.RENDER_DEPLOY_HOOK_BACKEND != ''
run: curl "${{ secrets.RENDER_DEPLOY_HOOK_BACKEND }}"

- name: Trigger Render Deploy (Frontend)
if: env.RENDER_DEPLOY_HOOK_FRONTEND != ''
Comment on lines +89 to +93
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These deploy steps are guarded by env.RENDER_DEPLOY_HOOK_BACKEND / env.RENDER_DEPLOY_HOOK_FRONTEND, but those env vars are never set in this workflow. As a result the steps will always be skipped and deploy won't trigger. Check secrets.RENDER_DEPLOY_HOOK_* in the if: condition (or set the env vars from secrets).

Suggested change
if: env.RENDER_DEPLOY_HOOK_BACKEND != ''
run: curl "${{ secrets.RENDER_DEPLOY_HOOK_BACKEND }}"
- name: Trigger Render Deploy (Frontend)
if: env.RENDER_DEPLOY_HOOK_FRONTEND != ''
if: secrets.RENDER_DEPLOY_HOOK_BACKEND != ''
run: curl "${{ secrets.RENDER_DEPLOY_HOOK_BACKEND }}"
- name: Trigger Render Deploy (Frontend)
if: secrets.RENDER_DEPLOY_HOOK_FRONTEND != ''

Copilot uses AI. Check for mistakes.
run: curl "${{ secrets.RENDER_DEPLOY_HOOK_FRONTEND }}"
123 changes: 114 additions & 9 deletions backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@google/generative-ai": "^0.24.1",
"@prisma/client": "^6.19.2",
"@types/socket.io": "^3.0.1",
"@types/twilio": "^3.19.2",
"bcrypt": "^6.0.0",
"cloudinary": "^2.9.0",
Comment on lines 39 to 44
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@types/twilio is a TypeScript-only dependency and should typically be in devDependencies (it isn't needed at runtime). Consider moving it to devDependencies to keep the production install footprint smaller.

Copilot uses AI. Check for mistakes.
"cors": "^2.8.6",
Expand All @@ -49,6 +50,7 @@
"mongoose": "^8.22.0",
"multer": "^2.1.1",
"redis": "^4.7.0",
"socket.io": "^4.8.3"
"socket.io": "^4.8.3",
"twilio": "^5.12.2"
}
}
Loading
Loading