diff --git a/.github/workflows/src/index.js b/.github/workflows/src/index.js index b08503db..e56fb392 100644 --- a/.github/workflows/src/index.js +++ b/.github/workflows/src/index.js @@ -39,6 +39,8 @@ const BOT_ACCOUNT_LOGIN = "GitHub-Education-bot" try { ;(async ()=>{ + const feedback = [] + if(actionEvent.name === "review_requested" && actionEvent.requestedReviewer.login !== BOT_ACCOUNT_LOGIN) { return true } @@ -78,6 +80,7 @@ try { try { content = isFilePathValid.isValid && await octokit.getContent(`_data/${actionEvent.pullAuthor}/${actionEvent.pullAuthor}.md`) } catch(err) { + feedpack.push("I was unable to view the content of the markdown file, please try again in a few minutes") console.log(err) } @@ -116,12 +119,12 @@ try { // - merge PR const userAgreesCoc = user2021 && user2021["Code of Conduct"] - const feedback = [] + let closePR = false if(user2020) { console.log("user already Participated in 2020") feedback.push("**I'm really sorry! It looks like you've already graduated in a previous year.**") - octokit.closePR() + closePR = true } else { if(!hasSdp) { console.log("User has not applied for SDP") @@ -182,6 +185,15 @@ ${ feedBackMessage } console.log(err) } + if(closePR) { + try { + octokit.closePR() + } catch(err) { + console.log("failed to close PR") + console.log(err) + } + } + if(feedback.length) { console.log(feedback.join('\n')) process.exit(1)