Skip to content

Commit

Permalink
allow remove non-existing label
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 7cd551d commit 5179bdf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cyborg/bin/follow-up-docs-issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

import * as core from '@actions/core'
import {handleError, obtainClient} from "@/common";
import {context} from "@actions/github";
import {PullRequestEditedEvent, PullRequestEvent, PullRequestOpenedEvent} from "@octokit/webhooks-types";
// @ts-expect-error moduleResolution:nodenext issue 54523
import {RequestError} from "@octokit/request-error";

const needFollowUpDocs = "[x] This PR requires documentation updates."

Expand All @@ -40,6 +43,12 @@ async function main() {
if (followUpDocs) {
await client.rest.issues.removeLabel({
owner, repo, issue_number: number, name: 'docs-not-need',
}).catch((e: RequestError) => {
if (e.status != 404) {
throw e;
} else {
core.debug("Labels to be removed do not exist.")
}
})
await client.rest.issues.addLabels({
owner, repo, issue_number: number, labels: ['docs-required'],
Expand All @@ -54,6 +63,12 @@ async function main() {
} else {
await client.rest.issues.removeLabel({
owner, repo, issue_number: number, name: 'docs-required'
}).catch((e: RequestError) => {
if (e.status != 404) {
throw e;
} else {
core.debug("Labels to be removed do not exist.")
}
})
await client.rest.issues.addLabels({
owner, repo, issue_number: number, labels: ['docs-not-need'],
Expand Down
1 change: 1 addition & 0 deletions cyborg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/request-error": "^6.1.1",
"@octokit/webhooks-types": "^7.5.1",
"conventional-commit-types": "^3.0.0",
"conventional-commits-parser": "^5.0.0",
Expand Down
10 changes: 10 additions & 0 deletions cyborg/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5179bdf

Please sign in to comment.