only do forgejo stuff when in action
All checks were successful
Gosec Check / Gosec Check (push) Successful in 53s
All checks were successful
Gosec Check / Gosec Check (push) Successful in 53s
This commit is contained in:
parent
dd7f28e061
commit
fe02c430ad
1 changed files with 32 additions and 40 deletions
72
cmd/root.go
72
cmd/root.go
|
@ -178,49 +178,41 @@ var rootCmd = &cobra.Command{
|
|||
|
||||
if isAction {
|
||||
action.AddStepSummary(markdownOutputStr)
|
||||
}
|
||||
|
||||
actionCtx, err := action.Context()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
forgeClient, err := forgejo.NewClient(actionCtx.ServerURL, forgejo.SetToken(action.GetInput("token")))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
repoOwner, repoName := actionCtx.Repo()
|
||||
|
||||
issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{
|
||||
Type: forgejo.IssueTypeIssue,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// This will trigger gosec
|
||||
file, err := os.OpenFile("testing.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModePerm)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
defer file.Close()
|
||||
|
||||
if len(issues) == 0 {
|
||||
if _, _, err := forgeClient.CreateIssue(repoOwner, repoName, forgejo.CreateIssueOption{
|
||||
Title: "GoSec Report",
|
||||
Body: markdownOutputStr,
|
||||
}); err != nil {
|
||||
actionCtx, err := action.Context()
|
||||
if 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)
|
||||
|
||||
forgeClient, err := forgejo.NewClient(actionCtx.ServerURL, forgejo.SetToken(action.GetInput("token")))
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
repoOwner, repoName := actionCtx.Repo()
|
||||
|
||||
issues, _, err := forgeClient.ListIssues(forgejo.ListIssueOption{
|
||||
Type: forgejo.IssueTypeIssue,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
if len(issues) == 0 {
|
||||
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