Skip to content

Commit

Permalink
latest version of commenter and exit if not a PR
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney committed Jan 21, 2022
1 parent 7404b0e commit d7f0147
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
9 changes: 7 additions & 2 deletions cmd/commenter/commenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func main() {

prNo, err := extractPullRequestNumber()
if err != nil {
fail(err.Error())
fmt.Println("Not a PR, nothing to comment on, exiting...")
return
}

c, err := commenter.NewCommenter(token, owner, repo, prNo)
Expand Down Expand Up @@ -110,7 +111,11 @@ func extractPullRequestNumber() (int, error) {
}
payload := data.(map[string]interface{})

return strconv.Atoi(fmt.Sprintf("%v", payload["number"]))
prNumber, err := strconv.Atoi(fmt.Sprintf("%v", payload["number"]))
if err != nil {
return 0, fmt.Errorf("not a valid PR")
}
return prNumber, nil
}

func formatUrls(urls []string) string {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/aquasecurity/tfsec-github-commenter-action

go 1.15

require github.com/owenrumney/go-github-pr-commenter v0.0.18
require github.com/owenrumney/go-github-pr-commenter v0.1.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASu
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/owenrumney/go-github-pr-commenter v0.0.18 h1:5iOxTRDzvr5m9o7R0l+8IcIYkMrgtDA3+Pw6U+4n0Qo=
github.com/owenrumney/go-github-pr-commenter v0.0.18/go.mod h1:FVpyF/OGnWrtYwe9DkRpJsIlxSPIOJstZAyGyDfC/rA=
github.com/owenrumney/go-github-pr-commenter v0.1.0 h1:P1AUqD1O4jSFSJbRldhNl88eVGOYQ3QuZke2OpyIAlY=
github.com/owenrumney/go-github-pr-commenter v0.1.0/go.mod h1:FVpyF/OGnWrtYwe9DkRpJsIlxSPIOJstZAyGyDfC/rA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ github.com/golang/protobuf/proto
github.com/google/go-github/v32/github
# github.com/google/go-querystring v1.0.0
github.com/google/go-querystring/query
# github.com/owenrumney/go-github-pr-commenter v0.0.18
# github.com/owenrumney/go-github-pr-commenter v0.1.0
## explicit
github.com/owenrumney/go-github-pr-commenter/commenter
# golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
Expand Down

0 comments on commit d7f0147

Please sign in to comment.