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

@ -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)
}
}
}
}
}