This commit is contained in:
parent
a0aa789a30
commit
d19c3075cd
1 changed files with 15 additions and 14 deletions
29
cmd/root.go
29
cmd/root.go
|
@ -192,31 +192,32 @@ var rootCmd = &cobra.Command{
|
|||
repoOwner, repoName := actionCtx.Repo()
|
||||
|
||||
issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{
|
||||
Type: forgejo.IssueTypeIssue,
|
||||
CreatedBy: "forgejo-actions",
|
||||
KeyWord: "GoSec",
|
||||
Type: forgejo.IssueTypeIssue,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if len(issues) == 0 {
|
||||
isFound := false
|
||||
for _, issue := range issues {
|
||||
if issue.Title == "GoSec Report" && strings.Contains(issue.Body, "GoSec Report:") && actionCtx.Repository == issue.Repository.FullName {
|
||||
isFound = true
|
||||
if _, _, err := forgeClient.EditIssue(repoOwner, repoName, issue.Index, forgejo.EditIssueOption{
|
||||
Body: &markdownOutputStr,
|
||||
}); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !isFound {
|
||||
if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{
|
||||
Title: "GoSec Report",
|
||||
Body: markdownOutputStr,
|
||||
}); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
} else {
|
||||
for _, issue := range issues {
|
||||
if issue.Title == "GoSec Report" && strings.Contains(issue.Body, "GoSec Report:") && actionCtx.Repository == issue.Repository.FullName {
|
||||
if _, _, err := forgeClient.EditIssue(repoOwner, repoName, issue.Index, forgejo.EditIssueOption{
|
||||
Body: &markdownOutputStr,
|
||||
}); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue