This commit is contained in:
parent
a0aa789a30
commit
d19c3075cd
1 changed files with 15 additions and 14 deletions
21
cmd/root.go
21
cmd/root.go
|
@ -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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue