feat: add build info to /api/health for deployment verification

- Return commitSha, commitMessage, and deploymentUrl from Vercel env vars
- Document verification workflow in CLAUDE.md
This commit is contained in:
Ajax Davis 2026-01-07 23:25:12 +10:00
parent efb28029ce
commit 728aeb8487
2 changed files with 47 additions and 1 deletions

View file

@ -1097,4 +1097,44 @@ Potential enhancements to the sync system:
- [ ] Create admin dashboard to monitor sync health
- [ ] Support GitHub stars syncing (requires GitHub API integration)
- [ ] Add sync metrics to Vercel Analytics
- [ ] Implement differential sync to reduce database writes
- [ ] Implement differential sync to reduce database writes
---
## Verifying Production Deployments
To verify that a deployment has been successfully pushed to production, fetch the `/api/health` endpoint:
```bash
curl https://tpmjs.com/api/health
```
**Response format:**
```json
{
"status": "ok",
"timestamp": "2025-01-07T13:30:00.000Z",
"build": {
"commitSha": "efb2802",
"commitMessage": "feat: add public chat page for agents",
"deploymentUrl": "tpmjs-xyz123.vercel.app"
},
"env": {
"hasDatabase": true,
"nodeEnv": "production"
}
}
```
**Key fields:**
- `commitSha` - The short git commit hash (7 chars) of the deployed code
- `commitMessage` - The commit message of the deployed commit
- `deploymentUrl` - The Vercel deployment URL
**Verification workflow:**
1. After pushing, check the latest commit: `git log --oneline -1`
2. Wait for CI and Vercel deployment to complete
3. Fetch `/api/health` and compare `commitSha` with your local commit
4. If they match, the deployment is live
**Note:** Vercel provides these values via environment variables (`VERCEL_GIT_COMMIT_SHA`, `VERCEL_GIT_COMMIT_MESSAGE`, `VERCEL_URL`) which are automatically available at runtime.

View file

@ -18,6 +18,12 @@ export async function GET(request: NextRequest) {
return NextResponse.json({
status: 'ok',
timestamp: new Date().toISOString(),
build: {
// Vercel provides these at runtime
commitSha: process.env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) || 'local',
commitMessage: process.env.VERCEL_GIT_COMMIT_MESSAGE || 'local',
deploymentUrl: process.env.VERCEL_URL || 'localhost',
},
env: {
hasDatabase: !!process.env.DATABASE_URL,
nodeEnv: process.env.NODE_ENV,