File tree Expand file tree Collapse file tree 4 files changed +39
-14
lines changed Expand file tree Collapse file tree 4 files changed +39
-14
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package main
3
3
import (
4
4
"flag"
5
5
"fmt"
6
- "github.com/variantdev/go-actions"
7
6
"github.com/variantdev/go-actions/pkg/pullvet"
8
7
"os"
9
8
)
@@ -45,7 +44,13 @@ func main() {
45
44
46
45
fs .Parse (os .Args [2 :])
47
46
48
- if err := cmd .Run (actions .PullRequestEvent ().PullRequest ); err != nil {
47
+ pr , err := pullvet .GetPullRequest ()
48
+ if err != nil {
49
+ fmt .Fprintf (os .Stderr , "%v\n " , err )
50
+ os .Exit (1 )
51
+ }
52
+
53
+ if err := cmd .Run (pr ); err != nil {
49
54
fatal ("%v\n " , err )
50
55
}
51
56
default :
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ package main
3
3
import (
4
4
"flag"
5
5
"fmt"
6
- "github.com/google/go-github/github"
7
- "github.com/variantdev/go-actions"
8
6
"github.com/variantdev/go-actions/pkg/pullvet"
9
7
"os"
10
8
)
@@ -23,17 +21,10 @@ func main() {
23
21
24
22
flag .Parse ()
25
23
26
- var pr * github.PullRequest
27
-
28
- checkRun , err := actions .CheckRunEvent ()
24
+ pr , err := pullvet .GetPullRequest ()
29
25
if err != nil {
30
- pull , err := actions .PullRequestEvent ()
31
- if err != nil {
32
- fmt .Fprintf (os .Stderr , "%v\n " , err )
33
- }
34
- pr = pull .PullRequest
35
- } else {
36
- pr = checkRun .CheckRun .PullRequests [0 ]
26
+ fmt .Fprintf (os .Stderr , "%v\n " , err )
27
+ os .Exit (1 )
37
28
}
38
29
39
30
if err := cmd .Run (pr ); err != nil {
Original file line number Diff line number Diff line change @@ -39,3 +39,11 @@ func CheckRunEvent() (*github.CheckRunEvent, error) {
39
39
}
40
40
return evt .(* github.CheckRunEvent ), nil
41
41
}
42
+
43
+ func CheckSuiteEvent () (* github.CheckSuiteEvent , error ) {
44
+ evt , err := github .ParseWebHook ("check_suite" , Event ())
45
+ if err != nil {
46
+ return nil , err
47
+ }
48
+ return evt .(* github.CheckSuiteEvent ), nil
49
+ }
Original file line number Diff line number Diff line change 4
4
"flag"
5
5
"fmt"
6
6
"github.com/google/go-github/github"
7
+ "github.com/variantdev/go-actions"
7
8
"github.com/variantdev/go-actions/pkg/cmd"
8
9
"os"
9
10
"regexp"
@@ -129,3 +130,23 @@ func formatFailures(failures []string) string {
129
130
}
130
131
return strings .Join (lines , "\n " )
131
132
}
133
+
134
+ func GetPullRequest () (* github.PullRequest , error ) {
135
+ var pr * github.PullRequest
136
+ checkSuite , err := actions .CheckSuiteEvent ()
137
+ if err != nil {
138
+ checkRun , err := actions .CheckRunEvent ()
139
+ if err != nil {
140
+ pull , err := actions .PullRequestEvent ()
141
+ if err != nil {
142
+ return nil , err
143
+ }
144
+ pr = pull .PullRequest
145
+ } else {
146
+ pr = checkRun .CheckRun .PullRequests [0 ]
147
+ }
148
+ } else {
149
+ pr = checkSuite .CheckSuite .PullRequests [0 ]
150
+ }
151
+ return pr , nil
152
+ }
You can’t perform that action at this time.
0 commit comments