@@ -6,19 +6,21 @@ const Codeowners = require('codeowners');
6
6
7
7
// Effectively the main function
8
8
async function run ( ) {
9
+ console . log ( "Starting with " , context )
10
+
9
11
// Tell folks they can merge
10
- if ( context . action === "pull_request_target" ) {
12
+ if ( context . eventName === "pull_request_target" ) {
11
13
commentOnMergablePRs ( )
12
14
}
13
15
14
16
// Merge if they say they have access
15
- if ( context . action === "issue_comment" ) {
17
+ if ( context . eventName === "issue_comment" ) {
16
18
mergeIfLGTMAndHasAccess ( )
17
19
}
18
20
}
19
21
20
22
async function commentOnMergablePRs ( ) {
21
- if ( context . action !== "pull_request_target" ) {
23
+ if ( context . eventName !== "pull_request_target" ) {
22
24
throw new Error ( "This function can only run when the workflow specifies `pull_request_target` in the `on:`." )
23
25
}
24
26
@@ -28,11 +30,16 @@ async function commentOnMergablePRs() {
28
30
const pr = context . payload . pull_request
29
31
const thisRepo = { owner : context . repo . owner , repo : context . repo . repo }
30
32
31
- core . info ( `\n\nLooking at PR: ${ pr . title } ` )
33
+ core . info ( `\n\nLooking at PR: ' ${ pr . title } ' for codeowners ` )
32
34
33
35
const changedFiles = await getPRChangedFiles ( octokit , thisRepo , pr . number )
36
+ console . log ( "changed files" , changedFiles )
34
37
const codeowners = findCodeOwnersForChangedFiles ( changedFiles , cwd )
35
-
38
+ console . log ( "owners for PR" , codeowners )
39
+
40
+ const co = new Codeowners ( cwd ) ;
41
+ console . log ( co . codeownersFilePath , co . codeownersDirectory )
42
+
36
43
if ( ! codeowners . length ) {
37
44
console . log ( "This PR does not have any code-owners" )
38
45
process . exit ( 0 )
@@ -69,7 +76,7 @@ ${ourSignature}`
69
76
70
77
71
78
async function mergeIfLGTMAndHasAccess ( ) {
72
- if ( context . action !== "issue_comment" ) {
79
+ if ( context . eventName !== "issue_comment" ) {
73
80
throw new Error ( "This GH action can only run when the workflow specifies `pull_request_target` in the `on:`." )
74
81
}
75
82
0 commit comments