Support de-duping issues (#65)

* De-dupe against open issues when dedupe_issues = true

* Update README

* Fix compile errors

* Add unit tests for issue.ts
This commit is contained in:
Spencer Small
2020-05-27 15:18:45 -07:00
committed by GitHub
parent 1c3165e2f5
commit 261cbab716
6 changed files with 154 additions and 9 deletions

View File

@@ -19,3 +19,28 @@ export function getIssueOption(body: string): IssueOption {
labels
}
}
export type GetIssuesFunc = (options: {
owner: string
repo: string
state: 'open' | 'closed' | 'all' | undefined
}) => Promise<{data: {title: string; number: number}[]}>
export async function getExistingIssueNumber(
getIssues: GetIssuesFunc,
repo: {
owner: string
repo: string
}
): Promise<number | null> {
const {data: issues} = await getIssues({
...repo,
state: 'open'
})
const iss = issues
.filter(i => i.title === core.getInput('issue_title'))
.shift()
return iss === undefined ? null : iss.number
}