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
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ logs
.env
.gitignore
npm-debug.log
*.md
*.md
.env.docker
99 changes: 99 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
name: CI-CD Pipeline

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
name: Run tests
runs-on: ubuntu-latest

services:
redis:
image: redis:latest
ports:
- 6379:6379
options: --health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5

postgres:
image: postgres:16-alpine
ports:
- 5432:5432
env:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
options: >-
--health-cmd "pg_isready -U test"
--health-interval 10s
--health-timeout 5s
--health-retries 5

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Generate Prisma Client
run: npx prisma generate
env:
DATABASE_URL: "postgresql://fake:fake@localhost:5432/fake"

- name: Run Prisma migrations
run: npx prisma migrate deploy
env:
DATABASE_URL: "postgresql://test:test@localhost:5432/testdb"

- name: Run tests
run: npm test
env:
NODE_ENV: test
BASE_URL: "http://localhost:3000"
DATABASE_URL: "postgresql://test:test@localhost:5432/testdb"
REDIS_URL: "redis://localhost:6379"
EMAIL_HOST: "smtp.gmail.com"
EMAIL_PORT: "587"
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
ACCESS_SECRET: ${{ secrets.ACCESS_SECRET }}
REFRESH_SECRET: ${{ secrets.REFRESH_SECRET }}
ACCESS_EXPIRES_IN: "15m"
REFRESH_EXPIRES_IN: "7d"
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}

deploy:
name: Deploy to Production
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"

- name: Install dependencies
run: npm ci --omit=dev

- name: Deploy to Production
run: echo "Deploying to production..."
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ node_modules

# Environment variables
.env
.env
.env.docker

/src/generated/prisma

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
ports:
- "5001:5001"
env_file:
- .env
- .env.docker

redis:
image: redis:alpine
Expand Down
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
testEnvironment: "node",
transform: {},
setupFiles: ["dotenv/config"],
testMatch: ["**/tests/**/*.test.js"],
testTimeout: 10000,
};
Loading
Loading