Skip to content

Commit

Permalink
pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 4, 2024
1 parent 761b445 commit ebbc1f1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/src/content/docs/reference/cli/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Options:
-od, --out-data <string> output file for data (.jsonl/ndjson will be aggregated). JSON schema information and validation will be included if available.
-oa, --out-annotations <string> output file for annotations (.csv will be rendered as csv, .jsonl/ndjson will be aggregated)
-ocl, --out-changelog <string> output file for changelogs
-prc, --pull-request-comment [string] create comment on a pull request. (default: "")
-prd, --pull-request-description [string] upsert comment on a pull request description. (default: "")
-prc, --pull-request-comment [string] create comment on a pull request.
-prd, --pull-request-description [string] upsert comment on a pull request description.
-prr, --pull-request-reviews create pull request reviews from annotations
-j, --json emit full JSON response to output
-y, --yaml emit full YAML response to output
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export async function cli() {
.option("-ocl, --out-changelog <string>", "output file for changelogs")
.option(
"-prc, --pull-request-comment [string]",
"create comment on a pull request.", ""
"create comment on a pull request."
)
.option(
"-prd, --pull-request-description [string]",
"upsert comment on a pull request description.", ""
"upsert comment on a pull request description."
)
.option(
"-prr, --pull-request-reviews",
Expand Down
16 changes: 10 additions & 6 deletions packages/cli/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export async function runScript(
outTrace: string
outAnnotations: string
outChangelogs: string
pullRequestComment: string
pullRequestDescription: string
pullRequestComment: string | boolean
pullRequestDescription: string | boolean
pullRequestReviews: boolean
outData: string
label: string
Expand Down Expand Up @@ -372,26 +372,30 @@ ${Array.from(files)
await githubCreatePullRequestReviews(script, info, res.annotations)
}

if (pullRequestComment !== undefined && res.text) {
if (pullRequestComment && res.text) {
const info = parseGHTokenFromEnv(process.env)
if (info.repository && info.issue) {
await githubCreateIssueComment(
script,
info,
res.text,
pullRequestComment || script.id
typeof pullRequestComment === "string"
? pullRequestComment
: script.id
)
}
}

if (pullRequestDescription !== undefined && res.text) {
if (pullRequestDescription && res.text) {
const info = parseGHTokenFromEnv(process.env)
if (info.repository && info.issue) {
await githubUpsetPullRequest(
script,
info,
res.text,
pullRequestDescription || script.id
typeof pullRequestDescription === "string"
? pullRequestDescription
: script.id
)
}
}
Expand Down

0 comments on commit ebbc1f1

Please sign in to comment.