Skip to content

Commit 0462357

Browse files
committed
Update the action JS
1 parent d77c91c commit 0462357

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

index.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ const Codeowners = require('codeowners');
66

77
// Effectively the main function
88
async function run() {
9+
console.log("Starting with ", context)
10+
911
// Tell folks they can merge
10-
if (context.action === "pull_request_target") {
12+
if (context.eventName === "pull_request_target") {
1113
commentOnMergablePRs()
1214
}
1315

1416
// Merge if they say they have access
15-
if (context.action === "issue_comment") {
17+
if (context.eventName === "issue_comment") {
1618
mergeIfLGTMAndHasAccess()
1719
}
1820
}
1921

2022
async function commentOnMergablePRs() {
21-
if (context.action !== "pull_request_target") {
23+
if (context.eventName !== "pull_request_target") {
2224
throw new Error("This function can only run when the workflow specifies `pull_request_target` in the `on:`.")
2325
}
2426

@@ -28,11 +30,16 @@ async function commentOnMergablePRs() {
2830
const pr = context.payload.pull_request
2931
const thisRepo = { owner: context.repo.owner, repo: context.repo.repo }
3032

31-
core.info(`\n\nLooking at PR: ${pr.title}`)
33+
core.info(`\n\nLooking at PR: '${pr.title}' for codeowners`)
3234

3335
const changedFiles = await getPRChangedFiles(octokit, thisRepo, pr.number)
36+
console.log("changed files", changedFiles)
3437
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+
3643
if (!codeowners.length) {
3744
console.log("This PR does not have any code-owners")
3845
process.exit(0)
@@ -69,7 +76,7 @@ ${ourSignature}`
6976

7077

7178
async function mergeIfLGTMAndHasAccess() {
72-
if (context.action !== "issue_comment") {
79+
if (context.eventName !== "issue_comment") {
7380
throw new Error("This GH action can only run when the workflow specifies `pull_request_target` in the `on:`.")
7481
}
7582

0 commit comments

Comments
 (0)