Skip to content

Commit a07f370

Browse files
author
Frank
committed
wip: github actions
1 parent 4d760a1 commit a07f370

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

packages/opencode/src/cli/cmd/github.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,6 @@ export const GithubRunCommand = cmd({
375375
const runUrl = `/${owner}/${repo}/actions/runs/${runId}`
376376
const shareBaseUrl = isMock ? "https://dev.opencode.ai" : "https://opencode.ai"
377377

378-
// TODO
379-
console.log("payload", payload)
380-
381378
let appToken: string
382379
let octoRest: Octokit
383380
let octoGraph: typeof graphql
@@ -428,7 +425,7 @@ export const GithubRunCommand = cmd({
428425
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
429426
if (await branchIsDirty()) {
430427
const summary = await summarize(response)
431-
await pushToCurrentBranch(summary)
428+
await pushToLocalBranch(summary)
432429
}
433430
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
434431
await updateComment(`${response}${footer({ image: !hasShared })}`)
@@ -454,7 +451,7 @@ export const GithubRunCommand = cmd({
454451
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
455452
if (await branchIsDirty()) {
456453
const summary = await summarize(response)
457-
await pushToCurrentBranch(summary)
454+
await pushToNewBranch(summary, branch)
458455
const pr = await createPR(
459456
repoData.data.default_branch,
460457
branch,
@@ -540,6 +537,7 @@ export const GithubRunCommand = cmd({
540537
const mdMatches = prompt.matchAll(/!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi)
541538
const tagMatches = prompt.matchAll(/<img .*?src="(https:\/\/github\.com\/user-attachments\/[^"]+)" \/>/gi)
542539
const matches = [...mdMatches, ...tagMatches].sort((a, b) => a.index - b.index)
540+
console.log("Images", JSON.stringify(matches, null, 2))
543541

544542
let offset = 0
545543
for (const m of matches) {
@@ -556,9 +554,6 @@ export const GithubRunCommand = cmd({
556554
},
557555
})
558556
if (!res.ok) {
559-
// TODO
560-
//console.log(res)
561-
//throw new Error("manual")
562557
console.error(`Failed to download image: ${url}`)
563558
continue
564559
}
@@ -791,8 +786,17 @@ export const GithubRunCommand = cmd({
791786
return `opencode/${type}${issueId}-${timestamp}`
792787
}
793788

794-
async function pushToCurrentBranch(summary: string) {
795-
console.log("Pushing to current branch...")
789+
async function pushToNewBranch(summary: string, branch: string) {
790+
console.log("Pushing to new branch...")
791+
await $`git add .`
792+
await $`git commit -m "${summary}
793+
794+
Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
795+
await $`git push -u origin ${branch}`
796+
}
797+
798+
async function pushToLocalBranch(summary: string) {
799+
console.log("Pushing to local branch...")
796800
await $`git add .`
797801
await $`git commit -m "${summary}
798802

0 commit comments

Comments
 (0)