Conversation
Greptile SummaryThis PR introduces Pipeline-as-Code (GitOps) support with three sync modes (Off / Push Only / Bi-directional), a All previously flagged security and validation issues have been successfully addressed:
One correctness issue remains: a malformed YAML file in a push event creates a permanently empty pipeline record in the database when the pipeline is new, because Confidence Score: 4/5
Sequence DiagramsequenceDiagram
participant GH as GitHub
participant WH as POST /api/webhooks/git
participant DB as PostgreSQL
participant GHAPI as GitHub Contents API
GH->>WH: Push event (x-hub-signature-256)
WH->>DB: findMany bidirectional envs
DB-->>WH: environments[]
WH->>WH: HMAC verify each secret (timingSafeEqual)
alt No match
WH-->>GH: 401 Invalid signature
end
WH->>WH: Parse JSON, validate branch, build envSlug
WH->>WH: Filter changed files by envSlug/ prefix
loop each changed YAML file
WH->>GHAPI: GET /repos/{owner}/{repo}/contents/{file}
GHAPI-->>WH: file content
WH->>WH: importVectorConfig(content, "yaml") ⚠️ before transaction
WH->>DB: $transaction(findFirst or create pipeline) [Serializable]
DB-->>WH: pipeline record
WH->>DB: $transaction(deleteMany nodes/edges, createMany nodes/edges)
WH->>DB: writeAuditLog(gitops.pipeline.imported) with try/catch
end
WH-->>GH: 200 { processed, results }
|
bd4c1c7 to
856a5a2
Compare
- POST /api/webhooks/git receives GitHub push events, verifies HMAC signature, fetches changed YAML files, and imports pipeline configs - environment.update now accepts gitOpsMode; auto-generates webhook secret when switching to bidirectional mode
- GitOps Mode selector (Off / Push Only / Bi-directional) - Webhook URL and secret display with copy-to-clipboard - Instructions for configuring GitHub webhook
…ments Warns users that manual changes may be overwritten by the next git push when the environment uses bidirectional GitOps mode.
- New operations/gitops.md with full setup guide for push-only and bi-directional modes, GitHub webhook setup instructions - Updated environments.md with GitOps Mode section - Added GitOps page to SUMMARY.md navigation
- Encrypt gitWebhookSecret via encrypt() before storing, decrypt on read - Add writeAuditLog call for gitops.pipeline.imported events - Remove unreachable TOML format branch (only YAML files are collected)
Ensures names match the same schema used by the tRPC pipeline.create procedure, preventing invalid characters from entering the database.
- Guard environment.get with withTeamAccess("VIEWER") to prevent
unauthenticated access to environment details
- Stop returning decrypted webhook secret from the get query; return
hasWebhookSecret boolean instead (secret only available via the
EDITOR-gated update mutation response)
- Hoist repo URL parsing and git token decryption out of the per-file
loop in the webhook handler to avoid redundant work
- Update GitSyncSection frontend to track webhook secret from mutation
response state rather than the query
Stop decrypting and returning the stored webhook HMAC secret on every environment.update call. The plaintext secret is now only included in the response when freshly generated (switching to bidirectional mode for the first time). Unrelated updates (rename, token rotation, etc.) no longer leak the credential. Also updates the UI hint to explain the secret is shown only once.
6c0771d to
2e608bc
Compare
Summary
gitOpsModeandgitWebhookSecretfields to the Environment model with database migrationPOST /api/webhooks/gitendpoint that receives GitHub push events, verifies HMAC signatures, fetches changed YAML files, and imports pipeline configurationsenvironment.updaterouter to acceptgitOpsMode; auto-generates webhook secret when switching to bidirectional modedocs/public/operations/gitops.mdguide and update environments docs and SUMMARY.mdTest plan
npx prisma migrate devand verify the migration applies cleanly/api/webhooks/gitwith valid HMAC and a push payload containing YAML changes; verify pipeline is created/updatednpx tsc --noEmitpasses with no errors