@@ -7,7 +7,7 @@ const {readFileSync} = require("fs")
7
7
8
8
// Effectively the main function
9
9
async function run ( ) {
10
- core . info ( "Running version 1.4.0 " )
10
+ core . info ( "Running version 1.4.1 " )
11
11
12
12
// Tell folks they can merge
13
13
if ( context . eventName === "pull_request_target" ) {
@@ -43,7 +43,7 @@ async function commentOnMergablePRs() {
43
43
core . info ( `Code-owners: \n - ${ codeowners . users . join ( "\n - " ) } ` )
44
44
core . info ( `Labels: \n - ${ codeowners . labels . join ( "\n - " ) } ` )
45
45
46
- if ( ! codeowners . length ) {
46
+ if ( ! codeowners . users . length ) {
47
47
console . log ( "This PR does not have any code-owners" )
48
48
process . exit ( 0 )
49
49
}
@@ -55,7 +55,7 @@ async function commentOnMergablePRs() {
55
55
if ( filesWhichArentOwned . length === 0 ) ownersWhoHaveAccessToAllFilesInPR . push ( owner )
56
56
} )
57
57
58
- if ( ! ownersWhoHaveAccessToAllFilesInPR . length ) {
58
+ if ( ! ownersWhoHaveAccessToAllFilesInPR . length ) {
59
59
console . log ( "This PR does not have any code-owners who own all of the files in the PR" )
60
60
listFilesWithOwners ( changedFiles , cwd )
61
61
process . exit ( 0 )
@@ -85,12 +85,13 @@ ${ourSignature}`
85
85
}
86
86
87
87
async function mergeIfLGTMAndHasAccess ( ) {
88
- if ( context . eventName !== "issue_comment" && context . eventName !== "pull_request_review" ) {
89
- throw new Error ( "This GH action can only run when the workflow specifies `pull_request_target` in the `on:`." )
88
+ const body = context . payload . comment ? context . payload . comment . body : context . payload . review . body
89
+ if ( ! body ) {
90
+ // For debugging #8
91
+ console . log ( JSON . stringify ( context ) )
90
92
}
91
93
92
- const body = context . payload . comment ? context . payload . comment . body : context . payload . review . body
93
- if ( ! body . toLowerCase ( ) . includes ( "lgtm" ) ) {
94
+ if ( ! body || ! body . toLowerCase ( ) . includes ( "lgtm" ) ) {
94
95
console . log ( "Comment does not include LGTM ('looks good to me') so not merging" )
95
96
process . exit ( 0 )
96
97
}
0 commit comments