Skip to content

Commit

Permalink
Add title and description to GitHub Action Investigator script (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan authored Sep 27, 2024
1 parent 175d331 commit de9e02d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 2 additions & 4 deletions packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function githubFromEnv(env: Record<string, string>): GithubConnectionInfo {
}

export async function githubParseEnv(
env: Record<string, string>
env: Record<string, string>,
options?: { issue?: number }
): Promise<GithubConnectionInfo> {
const res = githubFromEnv(env)
try {
Expand All @@ -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(
(
Expand Down
8 changes: 6 additions & 2 deletions packages/sample/genaisrc/gai.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit de9e02d

Please sign in to comment.