Skip to content

Commit 4743091

Browse files
committed
ci: merge CI and deploy into push-to-main workflow
Replace tag-based deployment with automatic deploy on push to main. PRs only run checks (type check + tests + build), no deploy. Remove the separate deploy.yml workflow.
1 parent ebeb6aa commit 4743091

File tree

3 files changed

+63
-89
lines changed

3 files changed

+63
-89
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI / Deploy
22

33
on:
44
push:
@@ -7,28 +7,28 @@ on:
77
branches: [main]
88

99
jobs:
10-
test:
10+
check:
1111
runs-on: ubuntu-latest
1212
permissions:
1313
id-token: write
1414
contents: read
1515
steps:
1616
- uses: actions/checkout@v4
17-
17+
1818
- name: Setup Node.js
1919
uses: actions/setup-node@v4
2020
with:
2121
node-version: '20'
22-
22+
2323
- name: Install dependencies
2424
run: npm install --legacy-peer-deps
25-
25+
2626
- name: Type check
2727
run: npm run check
2828

2929
- name: Run tests with coverage
3030
run: npm run test:coverage
31-
31+
3232
- name: Upload coverage to Codecov
3333
uses: codecov/codecov-action@v4
3434
with:
@@ -37,6 +37,60 @@ jobs:
3737
flags: unittests
3838
name: openboot-web-coverage
3939
fail_ci_if_error: false
40-
40+
41+
- name: Build
42+
run: npm run build
43+
44+
deploy:
45+
needs: check
46+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
47+
runs-on: ubuntu-latest
48+
permissions:
49+
id-token: write
50+
contents: read
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Setup Node.js
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: '20'
58+
59+
- name: Install dependencies
60+
run: npm install --legacy-peer-deps
61+
4162
- name: Build
4263
run: npm run build
64+
65+
- name: Run D1 Migrations
66+
env:
67+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
68+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
69+
run: npx wrangler d1 migrations apply openboot --remote
70+
71+
- name: Deploy
72+
uses: cloudflare/wrangler-action@v3
73+
with:
74+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
75+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
76+
77+
- name: Health Check
78+
run: |
79+
echo "Waiting 10 seconds for deployment to propagate..."
80+
sleep 10
81+
82+
echo "Running health check..."
83+
HEALTH_RESPONSE=$(curl -s https://openboot.dev/api/health)
84+
echo "Health check response: $HEALTH_RESPONSE"
85+
86+
STATUS=$(echo $HEALTH_RESPONSE | jq -r '.status')
87+
if [ "$STATUS" != "healthy" ]; then
88+
echo "Health check failed! Status: $STATUS"
89+
echo "Full response: $HEALTH_RESPONSE"
90+
exit 1
91+
fi
92+
93+
echo "Health check passed!"
94+
echo "API: $(echo $HEALTH_RESPONSE | jq -r '.checks.api')"
95+
echo "Database: $(echo $HEALTH_RESPONSE | jq -r '.checks.database')"
96+
echo "Version: $(echo $HEALTH_RESPONSE | jq -r '.version')"

.github/workflows/deploy.yml

Lines changed: 0 additions & 75 deletions
This file was deleted.

CLAUDE.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,9 @@ D1 (SQLite), no ORM — direct parameterized SQL via `env.DB.prepare(sql).bind(.
7878

7979
## CI/CD
8080

81-
Tag-based releases. Push to `main` runs CI only (tests + build). Push a version tag (`v*`) triggers deployment:
81+
Push to `main` runs CI (type check + tests + build) then auto-deploys. PRs only run CI, no deploy.
8282

83-
```bash
84-
git tag v1.2.3
85-
git push origin v1.2.3
86-
```
87-
88-
Deploy workflow: test → build → D1 migrations → wrangler deploy. Migrations run before deploy — safe for schema changes that new code depends on.
83+
Deploy pipeline: check (type check → test → build) → deploy (build → D1 migrations → wrangler deploy → health check). Migrations run before deploy — safe for schema changes that new code depends on.
8984

9085
## Testing
9186

0 commit comments

Comments
 (0)