diff --git a/packages/cli/src/run.ts b/packages/cli/src/run.ts index d3ee4cefa6..077f11fe2e 100644 --- a/packages/cli/src/run.ts +++ b/packages/cli/src/run.ts @@ -430,10 +430,8 @@ export async function runScript( let _ghInfo: GithubConnectionInfo = undefined const resolveGitHubInfo = async () => { - if (!_ghInfo) { - _ghInfo = await githubParseEnv(process.env) - if (pullRequest) _ghInfo.issue = pullRequest - } + if (!_ghInfo) + _ghInfo = await githubParseEnv(process.env, { issue: pullRequest }) return _ghInfo } let adoInfo: AzureDevOpsEnv = undefined diff --git a/packages/core/src/github.ts b/packages/core/src/github.ts index bfe8b44ecc..ff41fc9b23 100644 --- a/packages/core/src/github.ts +++ b/packages/core/src/github.ts @@ -57,7 +57,8 @@ function githubFromEnv(env: Record): GithubConnectionInfo { } export async function githubParseEnv( - env: Record + env: Record, + options?: { issue?: number } ): Promise { const res = githubFromEnv(env) try { @@ -76,6 +77,7 @@ export async function githubParseEnv( res.owner = owner.login res.repository = res.owner + "/" + res.repo } + if (!isNaN(options?.issue)) res.issue = options.issue if (!res.issue) { const { number: issue } = JSON.parse( ( diff --git a/packages/sample/genaisrc/gai.genai.mts b/packages/sample/genaisrc/gai.genai.mts index 9a0c6f66a3..3ddeda8883 100644 --- a/packages/sample/genaisrc/gai.genai.mts +++ b/packages/sample/genaisrc/gai.genai.mts @@ -3,6 +3,9 @@ import { Octokit } from "octokit" import { createPatch } from "diff" script({ + title: "GitHub Action Investigator", + description: + "Analyze GitHub Action runs to find the root cause of a failure", parameters: { workflow: { type: "string" }, failure_run_id: { type: "number" }, @@ -92,11 +95,12 @@ Analyze the diff in LOG_DIFF and provide a summary of the root cause of the fail If you cannot find the root cause, stop. -Generate a diff with suggested fixes. Use a diff format.` +Generate a diff with suggested fixes. Use a diff format. +- If you cannot locate the error, do not generate a diff.` writeText( `## Investigator report -- [run first failure](${ff.html_url}) +- [run failure](${ff.html_url}) - [run last success](${ls.html_url}) - [commit diff](https://github.com/${owner}/${repo}/compare/${ls.head_sha}...${ff.head_sha})