diff --git a/org/labelissue.ts b/org/labelissue.ts new file mode 100644 index 0000000..8189c22 --- /dev/null +++ b/org/labelissue.ts @@ -0,0 +1,30 @@ +import { danger, schedule } from "danger" + +const gh = danger.github as any +const issue = gh.issue +const repo = gh.repository + +const qWords: string[] = ["how", "who", "what", "where", "when", "why", "which"] + +if (issue.title.slice(-1) == "?") { + addLabel() +} else { + const title = issue.title.toLowerCase() + for (var i = 0; i < qWords.length; i++) { + if (title.startsWith(qWords[i])) { + addLabel() + break + } + } +} + +function addLabel() { + schedule(async () => { + await danger.github.api.issues.addLabels({ + owner: repo.owner.login, + repo: repo.name, + number: issue.number, + labels: ["question"], + }) + }) +} diff --git a/settings-peril.json b/settings-peril.json index 8d1cb3f..5a07293 100644 --- a/settings-peril.json +++ b/settings-peril.json @@ -4,9 +4,9 @@ }, "rules": { "pull_request": "RxSwiftCommunity/peril@org/all-prs.ts", + "pull_request.closed": "RxSwiftCommunity/peril@org/aeryn.ts", "issue": "RxSwiftCommunity/peril@org/all-issues.ts", - "pull_request.closed": "RxSwiftCommunity/peril@org/aeryn.ts" + "issue.opened": "RxSwiftCommunity/peril@org/labelissue.ts" }, - "repos": { - } + "repos": {} }