update issue listing
All checks were successful
Gosec Check / Gosec Check (push) Successful in 54s

This commit is contained in:
Shane C 2024-09-08 15:40:53 -04:00
parent a0aa789a30
commit d19c3075cd
Signed by: shanec
GPG key ID: E46B5FEA35B22FF9

View file

@ -193,30 +193,31 @@ var rootCmd = &cobra.Command{
issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{ issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{
Type: forgejo.IssueTypeIssue, Type: forgejo.IssueTypeIssue,
CreatedBy: "forgejo-actions",
KeyWord: "GoSec",
}) })
if err != nil { if err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
if len(issues) == 0 { isFound := false
if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{
Title: "GoSec Report",
Body: markdownOutputStr,
}); err != nil {
log.Fatalln(err)
}
} else {
for _, issue := range issues { for _, issue := range issues {
if issue.Title == "GoSec Report" && strings.Contains(issue.Body, "GoSec Report:") && actionCtx.Repository == issue.Repository.FullName { 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{ if _, _, err := forgeClient.EditIssue(repoOwner, repoName, issue.Index, forgejo.EditIssueOption{
Body: &markdownOutputStr, Body: &markdownOutputStr,
}); err != nil { }); err != nil {
log.Fatalln(err) log.Fatalln(err)
} }
break
} }
} }
if !isFound {
if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{
Title: "GoSec Report",
Body: markdownOutputStr,
}); err != nil {
log.Fatalln(err)
}
} }
} }