The open source coding agent.
TypeScript
Fix Github Pull Request Event (#6037)
Daniel Politoab2a6c45a393
diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.tsindex 607fc7caf2e..6bfc53184ef 100644--- a/packages/opencode/src/cli/cmd/github.ts+++ b/packages/opencode/src/cli/cmd/github.ts@@ -7,7 +7,7 @@ import { graphql } from "@octokit/graphql"import * as core from "@actions/core"import * as github from "@actions/github"import type { Context } from "@actions/github/lib/context"-import type { IssueCommentEvent, PullRequestReviewCommentEvent, PullRequestEvent } from "@octokit/webhooks-types"+import type { IssueCommentEvent, PullRequestReviewCommentEvent, WorkflowRunEvent, PullRequestEvent } from "@octokit/webhooks-types"import { UI } from "../ui"import { cmd } from "./cmd"import { ModelsDev } from "../../provider/models"@@ -401,10 +401,8 @@ export const GithubRunCommand = cmd({const oidcBaseUrl = normalizeOidcBaseUrl()const { owner, repo } = context.repo// For schedule events, payload has no issue/comment data- const payload = isCommentEvent- ? (context.payload as IssueCommentEvent | PullRequestReviewCommentEvent)- : undefined- const issueEvent = payload && isIssueCommentEvent(payload) ? payload : undefined+ const payload = (context.payload as IssueCommentEvent | PullRequestReviewCommentEvent | WorkflowRunEvent | PullRequestEvent)+ const issueEvent = isIssueCommentEvent(payload) ? payload : undefinedconst actor = isScheduleEvent ? undefined : context.actorconst issueId = isScheduleEvent@@ -423,7 +421,9 @@ export const GithubRunCommand = cmd({let shareId: string | undefinedlet exitCode = 0type PromptFiles = Awaited<ReturnType<typeof getUserPrompt>>["promptFiles"]- const triggerCommentId = payload?.comment.id+ const triggerCommentId = isCommentEvent+ ? (payload as IssueCommentEvent | PullRequestReviewCommentEvent).comment.id+ : undefinedconst useGithubToken = normalizeUseGithubToken()const commentType = isCommentEvent? context.eventName === "pull_request_review_comment"@@ -619,7 +619,7 @@ export const GithubRunCommand = cmd({}function isIssueCommentEvent(- event: IssueCommentEvent | PullRequestReviewCommentEvent,+ event: IssueCommentEvent | PullRequestReviewCommentEvent | WorkflowRunEvent | PullRequestEvent,): event is IssueCommentEvent {return "issue" in event}@@ -664,7 +664,7 @@ export const GithubRunCommand = cmd({if (!isCommentEvent) {return "Review this pull request"}- const body = payload!.comment.body.trim()+ const body = (payload as IssueCommentEvent | PullRequestReviewCommentEvent).comment.body.trim()const bodyLower = body.toLowerCase()if (mentions.some((m) => bodyLower === m)) {if (reviewContext) {