Skip to content

Commit 7149378

Browse files
Merge pull request #13 from SanjeevSaniel/dev
Dev
2 parents 73cf675 + 4b15a4e commit 7149378

File tree

121 files changed

+29932
-9201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+29932
-9201
lines changed

.github/workflows/ci.yml

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, dev]
6+
pull_request:
7+
branches: [main, dev]
8+
9+
env:
10+
NODE_VERSION: '20'
11+
12+
jobs:
13+
# Job 1: Code quality checks
14+
lint:
15+
name: Lint and Type Check
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ env.NODE_VERSION }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run ESLint
32+
run: npm run lint
33+
34+
- name: Run TypeScript type check
35+
run: npx tsc --noEmit
36+
37+
# Job 2: Run tests
38+
test:
39+
name: Run Tests
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ env.NODE_VERSION }}
50+
cache: 'npm'
51+
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Run unit tests
56+
run: npm run test
57+
env:
58+
CI: true
59+
60+
- name: Upload coverage reports
61+
uses: codecov/codecov-action@v4
62+
if: success()
63+
with:
64+
file: ./coverage/coverage-final.json
65+
flags: unittests
66+
name: codecov-umbrella
67+
continue-on-error: true
68+
69+
# Job 3: Build check
70+
build:
71+
name: Build Application
72+
runs-on: ubuntu-latest
73+
needs: [lint, test]
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Node.js
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: ${{ env.NODE_VERSION }}
83+
cache: 'npm'
84+
85+
- name: Install dependencies
86+
run: npm ci
87+
88+
- name: Build application
89+
run: npm run build
90+
env:
91+
# Mock environment variables for build
92+
DATABASE_URL: postgresql://mock:mock@localhost:5432/mock
93+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: pk_test_mock
94+
CLERK_SECRET_KEY: sk_test_mock
95+
96+
- name: Check build output
97+
run: |
98+
if [ ! -d ".next" ]; then
99+
echo "Build failed: .next directory not found"
100+
exit 1
101+
fi
102+
echo "Build successful"
103+
104+
# Job 4: Database migrations check
105+
migrations:
106+
name: Check Database Migrations
107+
runs-on: ubuntu-latest
108+
109+
steps:
110+
- name: Checkout code
111+
uses: actions/checkout@v4
112+
113+
- name: Setup Node.js
114+
uses: actions/setup-node@v4
115+
with:
116+
node-version: ${{ env.NODE_VERSION }}
117+
cache: 'npm'
118+
119+
- name: Install dependencies
120+
run: npm ci
121+
122+
- name: Check for migration conflicts
123+
run: |
124+
if [ -d "drizzle" ]; then
125+
echo "Checking migration files..."
126+
ls -la drizzle/
127+
else
128+
echo "No migrations directory found"
129+
fi
130+
131+
# Job 5: Security audit
132+
security:
133+
name: Security Audit
134+
runs-on: ubuntu-latest
135+
136+
steps:
137+
- name: Checkout code
138+
uses: actions/checkout@v4
139+
140+
- name: Setup Node.js
141+
uses: actions/setup-node@v4
142+
with:
143+
node-version: ${{ env.NODE_VERSION }}
144+
cache: 'npm'
145+
146+
- name: Run npm audit
147+
run: npm audit --audit-level=moderate
148+
continue-on-error: true
149+
150+
- name: Check for known vulnerabilities
151+
run: |
152+
npx audit-ci --moderate
153+
continue-on-error: true
154+
155+
# Job 6: Notify on failure (optional)
156+
notify:
157+
name: Notify on Failure
158+
runs-on: ubuntu-latest
159+
needs: [lint, test, build]
160+
if: failure()
161+
162+
steps:
163+
- name: Send notification
164+
run: |
165+
echo "CI pipeline failed. Workflow: ${{ github.workflow }}"
166+
echo "Commit: ${{ github.sha }}"
167+
echo "Author: ${{ github.actor }}"

.github/workflows/deploy.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
env:
10+
NODE_VERSION: '20'
11+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
12+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
13+
14+
jobs:
15+
# Deploy to Production
16+
deploy-production:
17+
name: Deploy to Production
18+
runs-on: ubuntu-latest
19+
if: github.ref == 'refs/heads/main'
20+
environment:
21+
name: production
22+
url: ${{ steps.deploy.outputs.url }}
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ env.NODE_VERSION }}
32+
cache: 'npm'
33+
34+
- name: Install Vercel CLI
35+
run: npm install --global vercel@latest
36+
37+
- name: Pull Vercel Environment Information
38+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
39+
40+
- name: Build Project Artifacts
41+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
42+
43+
- name: Deploy Project Artifacts to Vercel
44+
id: deploy
45+
run: |
46+
url=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }})
47+
echo "url=$url" >> $GITHUB_OUTPUT
48+
echo "Deployed to: $url"
49+
50+
- name: Run database migrations
51+
run: npm run db:migrate
52+
env:
53+
DATABASE_URL: ${{ secrets.DATABASE_URL }}
54+
continue-on-error: true
55+
56+
- name: Deployment Summary
57+
run: |
58+
echo "### Deployment Successful! :rocket:" >> $GITHUB_STEP_SUMMARY
59+
echo "" >> $GITHUB_STEP_SUMMARY
60+
echo "**Environment:** Production" >> $GITHUB_STEP_SUMMARY
61+
echo "**URL:** ${{ steps.deploy.outputs.url }}" >> $GITHUB_STEP_SUMMARY
62+
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
63+
echo "**Author:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
64+
65+
# Deploy to Staging (on dev branch)
66+
deploy-staging:
67+
name: Deploy to Staging
68+
runs-on: ubuntu-latest
69+
if: github.ref == 'refs/heads/dev'
70+
environment:
71+
name: staging
72+
url: ${{ steps.deploy.outputs.url }}
73+
74+
steps:
75+
- name: Checkout code
76+
uses: actions/checkout@v4
77+
78+
- name: Setup Node.js
79+
uses: actions/setup-node@v4
80+
with:
81+
node-version: ${{ env.NODE_VERSION }}
82+
cache: 'npm'
83+
84+
- name: Install Vercel CLI
85+
run: npm install --global vercel@latest
86+
87+
- name: Pull Vercel Environment Information
88+
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
89+
90+
- name: Build Project Artifacts
91+
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
92+
93+
- name: Deploy Project Artifacts to Vercel
94+
id: deploy
95+
run: |
96+
url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})
97+
echo "url=$url" >> $GITHUB_OUTPUT
98+
echo "Deployed to: $url"
99+
100+
- name: Deployment Summary
101+
run: |
102+
echo "### Deployment Successful! :rocket:" >> $GITHUB_STEP_SUMMARY
103+
echo "" >> $GITHUB_STEP_SUMMARY
104+
echo "**Environment:** Staging" >> $GITHUB_STEP_SUMMARY
105+
echo "**URL:** ${{ steps.deploy.outputs.url }}" >> $GITHUB_STEP_SUMMARY
106+
echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
107+
echo "**Author:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)