File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package main
3
3
import (
4
4
"flag"
5
5
"fmt"
6
+ "github.com/google/go-github/github"
6
7
"github.com/variantdev/go-actions"
7
8
"github.com/variantdev/go-actions/pkg/pullvet"
8
9
"os"
@@ -22,7 +23,20 @@ func main() {
22
23
23
24
flag .Parse ()
24
25
25
- if err := cmd .Run (actions .PullRequestEvent ().PullRequest ); err != nil {
26
+ var pr * github.PullRequest
27
+
28
+ checkRun , err := actions .CheckRunEvent ()
29
+ 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 ]
37
+ }
38
+
39
+ if err := cmd .Run (pr ); err != nil {
26
40
fmt .Fprintf (os .Stderr , "%v\n " , err )
27
41
os .Exit (1 )
28
42
}
Original file line number Diff line number Diff line change @@ -24,10 +24,18 @@ func Event() []byte {
24
24
return payload
25
25
}
26
26
27
- func PullRequestEvent () * github.PullRequestEvent {
27
+ func PullRequestEvent () ( * github.PullRequestEvent , error ) {
28
28
evt , err := github .ParseWebHook ("pull_request" , Event ())
29
29
if err != nil {
30
- panic (err )
30
+ return nil , err
31
+ }
32
+ return evt .(* github.PullRequestEvent ), nil
33
+ }
34
+
35
+ func CheckRunEvent () (* github.CheckRunEvent , error ) {
36
+ evt , err := github .ParseWebHook ("check_run" , Event ())
37
+ if err != nil {
38
+ return nil , err
31
39
}
32
- return evt .(* github.PullRequestEvent )
40
+ return evt .(* github.CheckRunEvent ), nil
33
41
}
You can’t perform that action at this time.
0 commit comments