feat: implement deployment sync module with Supabase persistence and …#613
Open
TechBroAfrica wants to merge 1 commit into
Open
feat: implement deployment sync module with Supabase persistence and …#613TechBroAfrica wants to merge 1 commit into
TechBroAfrica wants to merge 1 commit into
Conversation
|
@TechBroAfrica Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@TechBroAfrica fix workflow |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #544
PR: feat/be-branch-metadata-sync - Ingest and Sync GitHub Branch/PR Deployment Metadata
Description
This PR implements the backend database schema, ingestion webhook, and admin endpoints required to sync branch and PR deployment metadata. This enables operators to inspect preview deployments and contributor environments in a single location.
Key Changes
Database Migration: Added the migration script 20260627000000_create_branch_deployments_table.sql to define the public.branch_deployments table and create an index on pr_number.
Webhook Ingestion (POST /deployment-sync/webhook): Exposes a public endpoint to receive branch name, PR number, commit SHA, preview URL, status, and event timestamp.
Idempotency & Replays: The endpoint is safe to replay and handles duplicate deliveries.
Stale Updates: Compares incoming eventTimestamp with the stored database value, discarding updates that arrive out of order (stale updates).
Admin Queries:
GET /admin/deployments/branch/:branchName: Returns the deployment status for a given branch name.
GET /admin/deployments/pr/:prNumber: Returns an array of deployment histories for the specified PR number.
Both routes are guarded by ApiKeyGuard and require the admin scope.
Testing: Integrated full unit tests covering duplicate delivery, stale update checks, and database failure branches.
Verification Plan
Ensure the new unit test suites pass successfully:
bash
npm run test:unit src/deployment-sync/tests/deployment-sync.service.unit.spec.ts
npm run test:unit src/deployment-sync/tests/deployment-sync.controller.unit.spec.ts
2. Manual Verification
You can test the endpoints locally using curl:
Ingest metadata:
bash
curl -X POST http://localhost:4000/deployment-sync/webhook
-H "Content-Type: application/json"
-d '{
"branchName": "feat/be-branch-metadata-sync",
"prNumber": 60,
"commitSha": "abc123commitsha",
"previewUrl": "https://quickex-preview-pr-60.vercel.app",
"status": "success",
"eventTimestamp": "2026-06-27T08:00:00.000Z"
}'
Verify stale check:
bash
curl -X POST http://localhost:4000/deployment-sync/webhook
-H "Content-Type: application/json"
-d '{
"branchName": "feat/be-branch-metadata-sync",
"prNumber": 60,
"commitSha": "stale-commit-sha",
"previewUrl": "https://quickex-preview-pr-60.vercel.app",
"status": "failed",
"eventTimestamp": "2026-06-27T07:30:00.000Z"
}'
Verify that the response returns the original data from 2026-06-27T08:00:00.000Z and does not overwrite it.
Admin Query by Branch:
bash
curl -X GET http://localhost:4000/admin/deployments/branch/feat/be-branch-metadata-sync
-H "Authorization: Bearer <ADMIN_API_KEY>"