File tree Expand file tree Collapse file tree 2 files changed +25
-20
lines changed Expand file tree Collapse file tree 2 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -8,23 +8,25 @@ const renderMessage = require('./lib/message');
8
8
async function run ( ) {
9
9
try {
10
10
console . log ( `action: ${ github . context . payload . action } ` ) ;
11
- console . log ( `payload: ${ JSON . stringify ( github . context . payload ) } ` ) ;
11
+ console . log ( `[data] payload: ${ JSON . stringify ( github . context . payload ) } ` ) ;
12
12
13
13
const config = new Config ( core ) ;
14
- console . log ( `config: ${ JSON . stringify ( config ) } ` ) ;
14
+ console . log ( `[data] config: ${ JSON . stringify ( config ) } ` ) ;
15
15
16
16
const pull = new Pull ( github . context . payload ) ;
17
- console . log ( `pull: ${ JSON . stringify ( pull ) } ` ) ;
17
+ console . log ( `[data] pull (payload) : ${ JSON . stringify ( pull ) } ` ) ;
18
18
19
19
const token = core . getInput ( 'GITHUB_TOKEN' ) ;
20
20
const octokit = new github . GitHub ( token ) ;
21
21
22
+ console . log ( `[info] get reviews` ) ;
22
23
const reviews = await octokit . pulls . listReviews ( {
23
24
owner : pull . owner ,
24
25
repo : pull . repo ,
25
26
pull_number : pull . pull_number
26
27
} ) ;
27
28
29
+ console . log ( `[info] get checks` ) ;
28
30
const checks = await octokit . checks . listForRef ( {
29
31
owner : pull . owner ,
30
32
repo : pull . repo ,
@@ -33,6 +35,7 @@ async function run() {
33
35
34
36
pull . compileReviews ( reviews ) ;
35
37
pull . compileChecks ( checks ) ;
38
+ console . log ( `[data] pull (checks + reviews): ${ JSON . stringify ( pull ) } ` ) ;
36
39
37
40
console . log ( `merge: ${ pull . canMerge ( config ) } ` ) ;
38
41
Original file line number Diff line number Diff line change @@ -94,26 +94,28 @@ class Pull {
94
94
* @param {Object } checks check data from pull request
95
95
*/
96
96
compileChecks ( checks ) {
97
- const data = checks . data . check_runs ;
98
- let compiled = {
99
- total : checks . data . total_count ,
100
- completed : 0 ,
101
- success : 0
102
- } ;
97
+ if ( ! ! checks && ! ! checks . data ) {
98
+ const data = checks . data . check_runs ;
99
+ let compiled = {
100
+ total : checks . data . total_count ,
101
+ completed : 0 ,
102
+ success : 0
103
+ } ;
104
+
105
+ if ( data && Object . keys ( data ) . length > 0 ) {
106
+ data . forEach ( element => {
107
+ if ( element . status === "completed" ) {
108
+ compiled . completed ++ ;
109
+ }
103
110
104
- if ( data && Object . keys ( data ) . length > 0 ) {
105
- data . forEach ( element => {
106
- if ( element . status === "completed" ) {
107
- compiled . completed ++ ;
108
- }
111
+ if ( element . conclusion === "success" ) {
112
+ compiled . success ++ ;
113
+ }
114
+ } ) ;
115
+ }
109
116
110
- if ( element . conclusion === "success" ) {
111
- compiled . success ++ ;
112
- }
113
- } ) ;
117
+ this . checks = compiled ;
114
118
}
115
-
116
- this . checks = compiled ;
117
119
}
118
120
119
121
/**
You can’t perform that action at this time.
0 commit comments