diff --git a/cmd/root.go b/cmd/root.go index fd96d1b..497bcfc 100644 --- a/cmd/root.go +++ b/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) - } - } - } } }