feature: support create_issues, create_pr_comments flag (#93)
* doc: support new parameter create_issues, create_pr_comments * feature: support create_pr_comments flag * feature: support create_issues flag
This commit is contained in:
31
src/main.ts
31
src/main.ts
@@ -52,17 +52,34 @@ export async function run(): Promise<void> {
|
||||
})
|
||||
|
||||
if (ctx.event_name === 'pull_request') {
|
||||
await pr.createComment(
|
||||
token,
|
||||
github.context.repo.owner,
|
||||
github.context.repo.repo,
|
||||
ctx.event.number,
|
||||
audit.strippedStdout()
|
||||
)
|
||||
const createPRComments = core.getInput('create_pr_comments')
|
||||
if (!['true', 'false'].includes(createPRComments)) {
|
||||
throw new Error('Invalid input: create_pr_comments')
|
||||
}
|
||||
|
||||
if (createPRComments === 'true') {
|
||||
await pr.createComment(
|
||||
token,
|
||||
github.context.repo.owner,
|
||||
github.context.repo.repo,
|
||||
ctx.event.number,
|
||||
audit.strippedStdout()
|
||||
)
|
||||
}
|
||||
core.setFailed('This repo has some vulnerabilities')
|
||||
return
|
||||
} else {
|
||||
core.debug('open an issue')
|
||||
const createIssues = core.getInput('create_issues')
|
||||
if (!['true', 'false'].includes(createIssues)) {
|
||||
throw new Error('Invalid input: create_issues')
|
||||
}
|
||||
|
||||
if (createIssues === 'false') {
|
||||
core.setFailed('This repo has some vulnerabilities')
|
||||
return
|
||||
}
|
||||
|
||||
// remove control characters and create a code block
|
||||
const issueBody = audit.strippedStdout()
|
||||
const option: IssueOption = issue.getIssueOption(issueBody)
|
||||
|
||||
Reference in New Issue
Block a user