Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed May 14, 2024
1 parent 5179bdf commit 990db61
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cyborg/bin/follow-up-docs-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {PullRequestEditedEvent, PullRequestEvent, PullRequestOpenedEvent} from "
import {RequestError} from "@octokit/request-error";

const needFollowUpDocs = "[x] This PR requires documentation updates."
const labelDocsNotRequired = "docs-not-required"
const labelDocsRequired = "docs-required"

async function main() {
if (!context.payload.pull_request) {
Expand All @@ -41,37 +43,39 @@ async function main() {
}
const followUpDocs = checkPullRequestEvent(payload)
if (followUpDocs) {
core.info("Follow up docs.")
await client.rest.issues.removeLabel({
owner, repo, issue_number: number, name: 'docs-not-need',
owner, repo, issue_number: number, name: labelDocsNotRequired,
}).catch((e: RequestError) => {
if (e.status != 404) {
throw e;
} else {
core.debug("Labels to be removed do not exist.")
}
core.debug(`Label ${labelDocsNotRequired} not exist.`)
})
await client.rest.issues.addLabels({
owner, repo, issue_number: number, labels: ['docs-required'],
owner, repo, issue_number: number, labels: [labelDocsRequired],
})
await docsClient.rest.issues.create({
owner: 'GreptimeDB',
repo: 'docs',
title: `Update docs for ${title}`,
body: `A document change request is generated from ${html_url}`,
assignee: actor,
}).then((res) => {
core.info(`Created issue ${res.data}`)
})
} else {
core.info("No need to follow up docs.")
await client.rest.issues.removeLabel({
owner, repo, issue_number: number, name: 'docs-required'
owner, repo, issue_number: number, name: labelDocsRequired
}).catch((e: RequestError) => {
if (e.status != 404) {
throw e;
} else {
core.debug("Labels to be removed do not exist.")
}
core.debug(`Label ${labelDocsRequired} not exist.`)
})
await client.rest.issues.addLabels({
owner, repo, issue_number: number, labels: ['docs-not-need'],
owner, repo, issue_number: number, labels: [labelDocsNotRequired],
})
}
}
Expand Down

0 comments on commit 990db61

Please sign in to comment.