-
-
Notifications
You must be signed in to change notification settings - Fork 2
169 lines (142 loc) · 4.82 KB
/
Copy pathci-cd.yml
File metadata and controls
169 lines (142 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: CI/CD Pipeline
permissions:
contents: read
on:
push:
branches: [main]
paths:
- 'agentbot-backend/**'
- 'web/**'
- 'package*.json'
- '.github/workflows/ci-cd.yml'
pull_request:
branches: [main]
paths:
- 'agentbot-backend/**'
- 'web/**'
- 'package*.json'
jobs:
lint:
name: Lint & Secret Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: '22'
- name: Secret Scan
run: bash scripts/check-secrets.sh . || echo "Secret scan completed"
- name: ESLint (Backend)
run: cd agentbot-backend && npx eslint src --ext .ts --max-warnings 50 || true
backend:
name: Backend (TypeScript Build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: agentbot-backend/package-lock.json
- name: Install
run: cd agentbot-backend && npm ci
- name: Lint (Type Check)
run: cd agentbot-backend && npx tsc --noEmit
- name: Build
run: cd agentbot-backend && npm run build
- name: Test
run: cd agentbot-backend && npm test -- --passWithNoTests
frontend:
name: Frontend (Next.js Build)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: web/package-lock.json
- name: Install
run: cd web && npm ci
- name: Generate Prisma Client
run: cd web && npx prisma generate
- name: Build
run: cd web && npm run build
env:
NEXT_TELEMETRY_DISABLED: '1'
DATABASE_URL: 'postgresql://stub:stub@localhost/stub'
NEXTAUTH_SECRET: 'ci-build-stub-not-a-real-secret'
NEXTAUTH_URL: 'https://agentbot.sh'
INTERNAL_API_KEY: 'ci-build-stub'
BACKEND_API_URL: 'https://YOUR_SERVICE_URL'
- name: Run E2E Tests
run: cd web && (npx playwright test 2>/dev/null || echo "No E2E tests ran — skipping")
env:
BASE_URL: http://localhost:3000
pre-deploy-validation:
name: Pre-Deployment Validation
needs: [backend, frontend]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-node@v4.1.0
with:
node-version: '22'
- name: Run Pre-Deployment Validation
run: node scripts/pre-deployment-validation.js
deploy:
name: Deploy
needs: [pre-deploy-validation]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Summary
run: |
echo "✅ CI passed — deployments auto-triggering:"
echo " • Vercel → agentbot.sh (GitHub integration)"
echo " • Railway → agentbot-backend, borg-0, x402-gateway"
smoke-test:
name: Smoke Test (Production Health)
needs: [deploy]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Wait for deploys to settle
run: sleep 60
- name: Vercel — frontend health
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://agentbot.sh)
echo "Vercel / → $STATUS"
if [ "$STATUS" != "200" ] && [ "$STATUS" != "307" ] && [ "$STATUS" != "302" ]; then
echo "⚠️ Vercel returned $STATUS"
else
echo "✅ Vercel healthy"
fi
- name: Railway — backend health
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://YOUR_SERVICE_URL/health)
echo "Railway /health → $STATUS"
if [ "$STATUS" != "200" ]; then
echo "⚠️ Railway returned $STATUS"
else
echo "✅ Railway healthy"
fi
- name: Railway — x402 gateway health
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://YOUR_SERVICE_URL/health)
echo "x402 /health → $STATUS"
if [ "$STATUS" != "200" ]; then
echo "⚠️ x402 returned $STATUS"
else
echo "✅ x402 healthy"
fi
- name: Railway — browser automation health
run: |
STATUS=$(curl -s -o /dev/null -w "%{http_code}" --max-time 15 https://YOUR_SERVICE_URL/health)
echo "Browser /health → $STATUS"
if [ "$STATUS" != "200" ]; then
echo "⚠️ Browser returned $STATUS"
else
echo "✅ Browser healthy"
fi