Skip to content

Commit 5ab5e64

Browse files
committed
feat: Implement Invoice System Test with PDF generation, preview, and download functionality
- Added InvoiceSystemTest component for testing jsPDF invoice generation - Created DeliveryData interface for structured delivery information - Developed utility functions for generating, downloading, and previewing invoices - Enhanced SEO data structure for various pages - Configured package.json for workspace management and scripts - Set up Render and Vercel configurations for deployment
1 parent 1482313 commit 5ab5e64

Some content is hidden

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

84 files changed

+11232
-6066
lines changed

.env.example.ci

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Production Environment Variables for CI/CD
2+
# Add these as GitHub Secrets in your repository settings
3+
4+
# Render Configuration
5+
RENDER_DEPLOY_HOOK_URL=https://api.render.com/deploy/srv-xxxxxxxxxx # Get from Render dashboard
6+
API_URL=https://your-api-name.onrender.com # Your Render API URL
7+
8+
# Vercel Configuration
9+
VERCEL_TOKEN=your_vercel_token_here # Generate from Vercel dashboard
10+
VERCEL_ORG_ID=your_org_id # From Vercel project settings
11+
VERCEL_PROJECT_ID=your_project_id # From Vercel project settings
12+
CLIENT_URL=https://your-client.vercel.app # Your Vercel app URL
13+
14+
# Environment Variables for Client Build
15+
VITE_API_URL_PRODUCTION=https://your-api-name.onrender.com/api
16+
17+
# Optional: Slack/Discord notifications
18+
SLACK_WEBHOOK_URL=your_slack_webhook # For deployment notifications
19+
DISCORD_WEBHOOK_URL=your_discord_webhook # For deployment notifications

.github/workflows/deploy.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Deploy Aegis Express Logistics
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
NODE_VERSION: "18.x"
11+
12+
jobs:
13+
# Detect changes in monorepo
14+
detect-changes:
15+
runs-on: ubuntu-latest
16+
outputs:
17+
api-changed: ${{ steps.changes.outputs.api }}
18+
client-changed: ${{ steps.changes.outputs.client }}
19+
force-deploy: ${{ steps.changes.outputs.force }}
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- uses: dorny/paths-filter@v2
26+
id: changes
27+
with:
28+
filters: |
29+
api:
30+
- 'api/**'
31+
- 'package.json'
32+
- '.github/workflows/**'
33+
client:
34+
- 'client/**'
35+
- 'package.json'
36+
- '.github/workflows/**'
37+
force:
38+
- 'package.json'
39+
- '.github/workflows/**'
40+
41+
# Build and test API
42+
test-api:
43+
needs: detect-changes
44+
if: needs.detect-changes.outputs.api-changed == 'true' || needs.detect-changes.outputs.force-deploy == 'true'
45+
runs-on: ubuntu-latest
46+
defaults:
47+
run:
48+
working-directory: ./api
49+
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Setup Node.js
54+
uses: actions/setup-node@v4
55+
with:
56+
node-version: ${{ env.NODE_VERSION }}
57+
cache: "npm"
58+
cache-dependency-path: api/package-lock.json
59+
60+
- name: Install API dependencies
61+
run: npm ci
62+
63+
- name: Run API tests
64+
run: npm test || echo "No tests found"
65+
66+
- name: Lint API code
67+
run: npm run lint || echo "No linting configured"
68+
69+
# Build and test Client
70+
test-client:
71+
needs: detect-changes
72+
if: needs.detect-changes.outputs.client-changed == 'true' || needs.detect-changes.outputs.force-deploy == 'true'
73+
runs-on: ubuntu-latest
74+
defaults:
75+
run:
76+
working-directory: ./client
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Setup Node.js
82+
uses: actions/setup-node@v4
83+
with:
84+
node-version: ${{ env.NODE_VERSION }}
85+
cache: "npm"
86+
cache-dependency-path: client/package-lock.json
87+
88+
- name: Install Client dependencies
89+
run: npm ci
90+
91+
- name: Build Client
92+
run: npm run build
93+
env:
94+
VITE_API_URL: ${{ secrets.VITE_API_URL_PRODUCTION }}
95+
96+
- name: Run Client tests
97+
run: npm test || echo "No tests found"
98+
99+
- name: Upload build artifacts
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: client-build
103+
path: client/dist/
104+
retention-days: 1
105+
106+
# Deploy API to Render
107+
deploy-api:
108+
needs: [detect-changes, test-api]
109+
if: github.ref == 'refs/heads/main' && (needs.detect-changes.outputs.api-changed == 'true' || needs.detect-changes.outputs.force-deploy == 'true')
110+
runs-on: ubuntu-latest
111+
112+
steps:
113+
- name: Deploy to Render
114+
uses: fjogeleit/http-request-action@v1
115+
with:
116+
url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
117+
method: "POST"
118+
customHeaders: '{"Content-Type": "application/json"}'
119+
data: '{"branch": "main"}'
120+
121+
- name: Wait for deployment
122+
run: |
123+
echo "🚀 API deployment triggered on Render"
124+
echo "Monitor: https://dashboard.render.com"
125+
sleep 30
126+
127+
- name: Health check API
128+
run: |
129+
attempt=1
130+
max_attempts=10
131+
while [ $attempt -le $max_attempts ]; do
132+
if curl -f "${{ secrets.API_URL }}/health" 2>/dev/null; then
133+
echo "✅ API health check passed"
134+
break
135+
else
136+
echo "⏳ Attempt $attempt failed, retrying in 30s..."
137+
sleep 30
138+
attempt=$((attempt + 1))
139+
fi
140+
done
141+
142+
# Deploy Client to Vercel
143+
deploy-client:
144+
needs: [detect-changes, test-client]
145+
if: github.ref == 'refs/heads/main' && (needs.detect-changes.outputs.client-changed == 'true' || needs.detect-changes.outputs.force-deploy == 'true')
146+
runs-on: ubuntu-latest
147+
148+
steps:
149+
- uses: actions/checkout@v4
150+
151+
- name: Setup Node.js
152+
uses: actions/setup-node@v4
153+
with:
154+
node-version: ${{ env.NODE_VERSION }}
155+
156+
- name: Install Vercel CLI
157+
run: npm install --global vercel@latest
158+
159+
- name: Pull Vercel Environment Information
160+
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
161+
working-directory: ./client
162+
163+
- name: Build Project Artifacts
164+
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
165+
working-directory: ./client
166+
env:
167+
VITE_API_URL: ${{ secrets.VITE_API_URL_PRODUCTION }}
168+
169+
- name: Deploy Project Artifacts to Vercel
170+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
171+
working-directory: ./client
172+
173+
- name: Health check Client
174+
run: |
175+
sleep 30
176+
if curl -f "${{ secrets.CLIENT_URL }}" 2>/dev/null; then
177+
echo "✅ Client health check passed"
178+
else
179+
echo "❌ Client health check failed"
180+
exit 1
181+
fi
182+
183+
# Notification on success
184+
notify-success:
185+
needs: [deploy-api, deploy-client]
186+
if: always() && (needs.deploy-api.result == 'success' || needs.deploy-client.result == 'success')
187+
runs-on: ubuntu-latest
188+
189+
steps:
190+
- name: Notify deployment success
191+
run: |
192+
echo "🎉 Deployment completed successfully!"
193+
echo "🖥️ Client: ${{ secrets.CLIENT_URL }}"
194+
echo "🔧 API: ${{ secrets.API_URL }}"
195+
196+
# Notification on failure
197+
notify-failure:
198+
needs: [deploy-api, deploy-client]
199+
if: always() && (needs.deploy-api.result == 'failure' || needs.deploy-client.result == 'failure')
200+
runs-on: ubuntu-latest
201+
202+
steps:
203+
- name: Notify deployment failure
204+
run: |
205+
echo "❌ Deployment failed!"
206+
echo "Check the logs above for details."
207+
exit 1

.github/workflows/preview.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Preview Deployment
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
types: [opened, synchronize, reopened]
7+
8+
env:
9+
NODE_VERSION: "18.x"
10+
11+
jobs:
12+
# Deploy preview for PRs
13+
deploy-preview:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ env.NODE_VERSION }}
23+
24+
- name: Install Vercel CLI
25+
run: npm install --global vercel@latest
26+
27+
- name: Deploy to Vercel Preview
28+
run: |
29+
cd client
30+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
31+
vercel build --token=${{ secrets.VERCEL_TOKEN }}
32+
PREVIEW_URL=$(vercel deploy --token=${{ secrets.VERCEL_TOKEN }})
33+
echo "PREVIEW_URL=$PREVIEW_URL" >> $GITHUB_ENV
34+
35+
- name: Comment PR
36+
uses: actions/github-script@v7
37+
with:
38+
script: |
39+
github.rest.issues.createComment({
40+
issue_number: context.issue.number,
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
body: `## 🚀 Preview Deployment Ready!
44+
45+
Your changes have been deployed to a preview environment:
46+
47+
**🔗 Preview URL:** ${{ env.PREVIEW_URL }}
48+
49+
- ✅ Client build successful
50+
- 🔍 Review changes live
51+
- 🚀 Ready for testing
52+
53+
*This preview will be automatically deleted when the PR is closed.*`
54+
})

.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Health check endpoint
2+
/health
3+
4+
# Development files
5+
.env.local
6+
.env.development
7+
.env.test
8+
9+
# Build artifacts
10+
dist/
11+
build/
12+
13+
# Dependencies
14+
node_modules/
15+
16+
# IDE files
17+
.vscode/
18+
.idea/
19+
20+
# OS files
21+
.DS_Store
22+
Thumbs.db
23+
24+
# Logs
25+
*.log
26+
logs/
27+
28+
# Temporary files
29+
tmp/
30+
temp/
31+
32+
# Coverage reports
33+
coverage/
34+
35+
# Deployment specific
36+
.vercel
37+
.render
38+
39+
# API specific ignores
40+
api/.env
41+
api/uploads/
42+
api/logs/
43+
44+
# Client specific ignores
45+
client/.env.local
46+
client/dist/
47+
client/build/

0 commit comments

Comments
 (0)