diff --git a/src/events/workflow_run.completed/checklint.ts b/src/events/workflow_run.completed/checklint.ts index f7ed318..0b5d2de 100644 --- a/src/events/workflow_run.completed/checklint.ts +++ b/src/events/workflow_run.completed/checklint.ts @@ -12,19 +12,22 @@ export default async (context: Context<"workflow_run.completed">) => { const { owner, repo } = context.repo(); const workflowRun = context.payload.workflow_run; - if (workflowRun.conclusion === "success") { - const pullRequests = workflowRun.pull_requests as Array<{ number: number }>; - if (!pullRequests || pullRequests.length === 0) return; - - const pull_number = pullRequests[0].number; + const pull_number = await resolvePullNumber( + context, + workflowRun, + owner, + repo, + ); + if (!pull_number) return; + if (workflowRun.conclusion === "success") { const body = [ "> [!NOTE]", "> Linting checks passed successfully πŸŽ‰", "", "All formatting and code quality checks are clean.", "", - "You’re good to merge πŸš€", + "You're good to merge πŸš€", ].join("\n"); await context.octokit.rest.issues.createComment({ @@ -37,13 +40,6 @@ export default async (context: Context<"workflow_run.completed">) => { return; } - // Find the PR associated with this workflow run - const pullRequests = workflowRun.pull_requests as Array<{ number: number }>; - - if (!pullRequests || pullRequests.length === 0) return; - - const pull_number = pullRequests[0].number; - const logsUrl = `https://github.com/${owner}/${repo}/actions/runs/${workflowRun.id}`; const body = [ @@ -77,3 +73,30 @@ export default async (context: Context<"workflow_run.completed">) => { body, }); }; + +async function resolvePullNumber( + context: Context<"workflow_run.completed">, + workflowRun: Context<"workflow_run.completed">["payload"]["workflow_run"], + owner: string, + repo: string, +): Promise { + const directPRs = workflowRun.pull_requests as Array<{ number: number }>; + if (directPRs?.length > 0) { + return directPRs[0].number; + } + + const headBranch = workflowRun.head_branch; + const headSha = workflowRun.head_sha; + + if (!headBranch) return null; + + const { data: prs } = await context.octokit.rest.pulls.list({ + owner, + repo, + state: "open", + head: `${owner}:${headBranch}`, + }); + + const match = prs.find((pr) => pr.head.sha === headSha); + return match?.number ?? null; +} diff --git a/src/index.html b/src/index.html index e174a4a..aabb1cb 100644 --- a/src/index.html +++ b/src/index.html @@ -21,7 +21,6 @@ --text: #e5e7ff; --muted: #9194b8; --accent: #8b8dff; - --accent-glow: rgba(139, 141, 255, 0.35); } * { @@ -91,8 +90,6 @@ line-height: 1.05; margin-bottom: 24px; - - text-shadow: 0 0 30px var(--accent-glow); } .accent {