From 900962e003300d7d36d3a2c0df9440e3bb6a808f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80?= Date: Fri, 23 Oct 2026 23:21:21 +0800 Subject: [PATCH] fix(filter): read each event branch correctly Deployment and check branches live in event-specific nested fields. Read those fields and remove only the actual leading ref prefix. --- server/lib/events/filter-ast.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/server/lib/events/filter-ast.ts b/server/lib/events/filter-ast.ts index a69acd8..4baca79 100644 --- a/server/lib/events/filter-ast.ts +++ b/server/lib/events/filter-ast.ts @@ -130,7 +130,7 @@ function extractBranch(event: WebhookEvent): string | undefined { const p = event.payload; switch (event.event) { case "push": - return typeof p.ref === "string" ? p.ref.replace("refs/heads/", "") : undefined; + return typeof p.ref === "string" ? p.ref.replace(/^refs\/heads\//, "") : undefined; case "pull_request": case "pull_request_review": case "pull_request_review_comment": @@ -142,14 +142,22 @@ function extractBranch(event: WebhookEvent): string | undefined { return (p.workflow_run as { head_branch?: string } | undefined)?.head_branch; case "check_suite": return (p.check_suite as { head_branch?: string } | undefined)?.head_branch; + case "check_run": + return (p.check_run as { check_suite?: { head_branch?: string } } | undefined)?.check_suite + ?.head_branch; case "workflow_job": return (p.workflow_job as { head_branch?: string } | undefined)?.head_branch; case "deployment": - return typeof p.ref === "string" ? p.ref.replace("refs/heads/", "") : undefined; + case "deployment_status": { + // The deployed ref lives on the deployment object (a top-level `ref` is + // only read as a fallback). + const ref = (p.deployment as { ref?: unknown } | undefined)?.ref ?? p.ref; + return typeof ref === "string" ? ref.replace(/^refs\/heads\//, "") : undefined; + } case "commit_comment": return undefined; case "code_scanning_alert": - return typeof p.ref === "string" ? p.ref : undefined; + return typeof p.ref === "string" ? p.ref.replace(/^refs\/heads\//, "") : undefined; default: return undefined; }