wip: github actions
This commit is contained in:
@@ -375,9 +375,6 @@ export const GithubRunCommand = cmd({
|
|||||||
const runUrl = `/${owner}/${repo}/actions/runs/${runId}`
|
const runUrl = `/${owner}/${repo}/actions/runs/${runId}`
|
||||||
const shareBaseUrl = isMock ? "https://dev.opencode.ai" : "https://opencode.ai"
|
const shareBaseUrl = isMock ? "https://dev.opencode.ai" : "https://opencode.ai"
|
||||||
|
|
||||||
// TODO
|
|
||||||
console.log("payload", payload)
|
|
||||||
|
|
||||||
let appToken: string
|
let appToken: string
|
||||||
let octoRest: Octokit
|
let octoRest: Octokit
|
||||||
let octoGraph: typeof graphql
|
let octoGraph: typeof graphql
|
||||||
@@ -428,7 +425,7 @@ export const GithubRunCommand = cmd({
|
|||||||
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
||||||
if (await branchIsDirty()) {
|
if (await branchIsDirty()) {
|
||||||
const summary = await summarize(response)
|
const summary = await summarize(response)
|
||||||
await pushToCurrentBranch(summary)
|
await pushToLocalBranch(summary)
|
||||||
}
|
}
|
||||||
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
|
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
|
||||||
await updateComment(`${response}${footer({ image: !hasShared })}`)
|
await updateComment(`${response}${footer({ image: !hasShared })}`)
|
||||||
@@ -454,7 +451,7 @@ export const GithubRunCommand = cmd({
|
|||||||
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
||||||
if (await branchIsDirty()) {
|
if (await branchIsDirty()) {
|
||||||
const summary = await summarize(response)
|
const summary = await summarize(response)
|
||||||
await pushToCurrentBranch(summary)
|
await pushToNewBranch(summary, branch)
|
||||||
const pr = await createPR(
|
const pr = await createPR(
|
||||||
repoData.data.default_branch,
|
repoData.data.default_branch,
|
||||||
branch,
|
branch,
|
||||||
@@ -540,6 +537,7 @@ export const GithubRunCommand = cmd({
|
|||||||
const mdMatches = prompt.matchAll(/!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi)
|
const mdMatches = prompt.matchAll(/!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi)
|
||||||
const tagMatches = prompt.matchAll(/<img .*?src="(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)
|
const matches = [...mdMatches, ...tagMatches].sort((a, b) => a.index - b.index)
|
||||||
|
console.log("Images", JSON.stringify(matches, null, 2))
|
||||||
|
|
||||||
let offset = 0
|
let offset = 0
|
||||||
for (const m of matches) {
|
for (const m of matches) {
|
||||||
@@ -556,9 +554,6 @@ export const GithubRunCommand = cmd({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
// TODO
|
|
||||||
//console.log(res)
|
|
||||||
//throw new Error("manual")
|
|
||||||
console.error(`Failed to download image: ${url}`)
|
console.error(`Failed to download image: ${url}`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -791,8 +786,17 @@ export const GithubRunCommand = cmd({
|
|||||||
return `opencode/${type}${issueId}-${timestamp}`
|
return `opencode/${type}${issueId}-${timestamp}`
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pushToCurrentBranch(summary: string) {
|
async function pushToNewBranch(summary: string, branch: string) {
|
||||||
console.log("Pushing to current branch...")
|
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 add .`
|
||||||
await $`git commit -m "${summary}
|
await $`git commit -m "${summary}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user