summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-07-25 19:05:55 -0400
committerFrank <[email protected]>2025-07-25 19:05:55 -0400
commita07f37073b5726ef53c1f34a46990bd99cce59de (patch)
treefce4d0fdbe5b3837ee644d924e1b0c46fdfedb21
parent4d760a1984acb287adc42a0a8f7bf0b2cd5c5d79 (diff)
downloadopencode-a07f37073b5726ef53c1f34a46990bd99cce59de.tar.gz
opencode-a07f37073b5726ef53c1f34a46990bd99cce59de.zip
wip: github actions
-rw-r--r--packages/opencode/src/cli/cmd/github.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts
index bd4082cd2..5256a9639 100644
--- a/packages/opencode/src/cli/cmd/github.ts
+++ b/packages/opencode/src/cli/cmd/github.ts
@@ -375,9 +375,6 @@ export const GithubRunCommand = cmd({
const runUrl = `/${owner}/${repo}/actions/runs/${runId}`
const shareBaseUrl = isMock ? "https://dev.opencode.ai" : "https://opencode.ai"
- // TODO
- console.log("payload", payload)
-
let appToken: string
let octoRest: Octokit
let octoGraph: typeof graphql
@@ -428,7 +425,7 @@ export const GithubRunCommand = cmd({
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
if (await branchIsDirty()) {
const summary = await summarize(response)
- await pushToCurrentBranch(summary)
+ await pushToLocalBranch(summary)
}
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
await updateComment(`${response}${footer({ image: !hasShared })}`)
@@ -454,7 +451,7 @@ export const GithubRunCommand = cmd({
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
if (await branchIsDirty()) {
const summary = await summarize(response)
- await pushToCurrentBranch(summary)
+ await pushToNewBranch(summary, branch)
const pr = await createPR(
repoData.data.default_branch,
branch,
@@ -540,6 +537,7 @@ export const GithubRunCommand = cmd({
const mdMatches = prompt.matchAll(/!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi)
const tagMatches = prompt.matchAll(/<img .*?src="(https:\/\/github\.com\/user-attachments\/[^"]+)" \/>/gi)
const matches = [...mdMatches, ...tagMatches].sort((a, b) => a.index - b.index)
+ console.log("Images", JSON.stringify(matches, null, 2))
let offset = 0
for (const m of matches) {
@@ -556,9 +554,6 @@ export const GithubRunCommand = cmd({
},
})
if (!res.ok) {
- // TODO
- //console.log(res)
- //throw new Error("manual")
console.error(`Failed to download image: ${url}`)
continue
}
@@ -791,8 +786,17 @@ export const GithubRunCommand = cmd({
return `opencode/${type}${issueId}-${timestamp}`
}
- async function pushToCurrentBranch(summary: string) {
- console.log("Pushing to current branch...")
+ async function pushToNewBranch(summary: string, branch: string) {
+ console.log("Pushing to new branch...")
+ await $`git add .`
+ await $`git commit -m "${summary}
+
+Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
+ await $`git push -u origin ${branch}`
+ }
+
+ async function pushToLocalBranch(summary: string) {
+ console.log("Pushing to local branch...")
await $`git add .`
await $`git commit -m "${summary}