-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
# name: Create PR | ||
name: Create PR | ||
|
||
# on: | ||
# issues: | ||
# types: [opened, edited, labeled, unlabeled] | ||
# issue_comment: | ||
# types: [created, edited, deleted] | ||
on: | ||
issues: | ||
types: [opened, edited, labeled, unlabeled] | ||
issue_comment: | ||
types: [created, edited, deleted] | ||
|
||
# jobs: | ||
# handle_issue: | ||
# runs-on: ubuntu-latest | ||
# name: Create PR | ||
# steps: | ||
# - name: Checkout repository | ||
# uses: actions/checkout@v3 | ||
# - name: Setup Deno | ||
# uses: denoland/setup-deno@v1 | ||
# with: | ||
# deno-version: 1.38.3 | ||
# - name: generate UI | ||
# env: | ||
# GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
# OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
# run: deno run -A prompts/ui-gen.ts | ||
jobs: | ||
handle_issue: | ||
runs-on: ubuntu-latest | ||
name: Create PR | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
- name: Setup Deno | ||
uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: 1.38.3 | ||
- name: generate UI | ||
env: | ||
GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
run: deno run -A prompts/ui-gen.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { join } from "https://deno.land/[email protected]/path/mod.ts"; | |
import { getCode } from "./common.ts"; | ||
|
||
type IssueEvent = { | ||
action: string; | ||
issue: { | ||
body: string; | ||
number: number; | ||
|
@@ -219,7 +220,7 @@ async function main() { | |
}) | ||
).default; | ||
|
||
console.log(githubEvent.issue); | ||
console.log(githubEvent.action, githubEvent.issue); | ||
|
||
if (githubEvent.issue.labels.every((l) => l.name !== uiGenLabel)) { | ||
return; | ||
|
@@ -229,28 +230,33 @@ async function main() { | |
return; | ||
} | ||
|
||
const isPr = Boolean(githubEvent.issue.pull_request); | ||
const eventName = Deno.env.get("GITHUB_EVENT_NAME"); | ||
assert(eventName, "failed to get event name"); | ||
|
||
// ignore non-comments event in PR | ||
if (isPr && eventName === "issues") { | ||
return; | ||
} | ||
|
||
const owner = Deno.env.get("GITHUB_REPOSITORY_OWNER"); | ||
assert(owner, "failed to get repo owner"); | ||
|
||
let repo = Deno.env.get("GITHUB_REPOSITORY"); | ||
assert(repo, "failed to get repo name"); | ||
repo = repo.replace(`${owner}/`, ""); | ||
|
||
const branch = `ui-gen-issue-${githubEvent.issue.number}`; | ||
const issue = isPr | ||
? await getConnectedIssue(owner, repo, githubEvent.issue.body) | ||
: githubEvent.issue; | ||
|
||
let issue: { number: number; body?: string | null } = { | ||
number: -1, | ||
body: "", | ||
}; | ||
let pr: { number: number } = { number: -1 }; | ||
const branch = `ui-gen-issue-${issue.number}`; | ||
|
||
if (githubEvent.issue.pull_request) { | ||
let pr: { number: number } = { number: -1 }; | ||
if (isPr) { | ||
// is PR event | ||
pr = githubEvent.issue; | ||
issue = await getConnectedIssue(owner, repo, githubEvent.issue.body); | ||
} else { | ||
issue = githubEvent.issue; | ||
|
||
const connectedPrNumber = await getConnectedPr(owner, repo, issue.number); | ||
pr = connectedPrNumber | ||
? ( | ||
|