diff --git a/github-actions/trigger-issue/add-preliminary-comment/preliminary-update-comment.js b/github-actions/trigger-issue/add-preliminary-comment/preliminary-update-comment.js index 7ec26b6f79..66731647c4 100644 --- a/github-actions/trigger-issue/add-preliminary-comment/preliminary-update-comment.js +++ b/github-actions/trigger-issue/add-preliminary-comment/preliminary-update-comment.js @@ -1,11 +1,11 @@ -const fs = require("fs"); -const postComment = require('../../utils/post-issue-comment'); -const formatComment = require('../../utils/format-comment'); +var fs = require("fs") +const postComment = require('../../utils/post-issue-comment') +const formatComment = require('../../utils/format-comment') const getTimeline = require('../../utils/get-timeline'); // Global variables -var github; -var context; +var github +var context /** * @description - This function is the entry point into the javascript file, it formats the md file based on the result of the previous step and then posts it to the issue @@ -16,19 +16,19 @@ var context; */ async function main({ g, c }, { shouldPost, issueNum }){ - github = g; - context = c; + github = g + context = c // If the previous action returns a false, stop here if(shouldPost === false){ - console.log('No need to post comment.'); - return; + console.log('No need to post comment.') + return } //Else we make the comment with the issuecreator's github handle instead of the placeholder. else{ - const instructions = await makeComment(); + const instructions = await makeComment() if(instructions !== null){ // the actual creation of the comment in github - await postComment(issueNum, instructions, github, context); + await postComment(issueNum, instructions, github, context) } } } @@ -40,65 +40,28 @@ async function main({ g, c }, { shouldPost, issueNum }){ async function makeComment(){ // Setting all the variables which formatComment is to be called with - let issueAssignee = context.payload.issue.assignee.login; - const eventDescriptions = await getTimeline(context.payload.issue.number, github, context); + var issueAssignee = context.payload.issue.assignee.login + const eventdescriptions = await getTimeline(context.payload.issue.number, github, context) + console.log(eventdescriptions.length) //adding the code to find out the latest person assigned the issue - for(let i = eventDescriptions.length - 1; i >= 0; i -= 1){ - if(eventDescriptions[i].event == 'assigned'){ - issueAssignee = eventDescriptions[i].assignee.login; - break; + for(var i = eventdescriptions.length - 1 ; i>=0; i-=1){ + if(eventdescriptions[i].event == 'assigned'){ + issueAssignee = eventdescriptions[i].assignee.login + break } } - const isDraft = context.payload.issue.labels.find((label) => label.name == 'Draft') ? true : false; - - const queryColumn = `query($owner:String!, $name:String!, $number:Int!) { - repository(owner:$owner, name:$name) { - issue(number:$number) { - projectCards { - nodes { - column { - name - } - } - } - } - } - }`; - const variables = { - owner: context.repo.owner, - name: context.repo.repo, - number: context.payload.issue.number - }; - const resColumn = await github.graphql(queryColumn, variables); - const columnName = resColumn.repository.issue.projectCards.nodes[0].column.name; - - let filename = 'preliminary-update.md'; - - // Unassign if issue is in New Issue Approval column of Project Board and is not labeled 'Draft' - if (!isDraft && columnName == 'New Issue Approval') { - filename = 'unassign-from-NIA.md'; - - await github.rest.issues.removeAssignees({ - owner: variables.owner, - repo: variables.name, - issue_number: variables.number, - assignees: [issueAssignee], - }); - } - - const filePathToFormat = './github-actions/trigger-issue/add-preliminary-comment/' + filename; const commentObject = { replacementString: issueAssignee, placeholderString: '${issueAssignee}', - filePathToFormat: filePathToFormat, + filePathToFormat: './github-actions/trigger-issue/add-preliminary-comment/preliminary-update.md', textToFormat: null - }; + } // creating the comment with issue assignee's name and returning it! - const commentWithIssueAssignee = formatComment(commentObject, fs); - return commentWithIssueAssignee; + const commentWithIssueAssignee = formatComment(commentObject, fs) + return commentWithIssueAssignee } -module.exports = main; +module.exports = main diff --git a/github-actions/trigger-issue/add-preliminary-comment/unassign-from-NIA.md b/github-actions/trigger-issue/add-preliminary-comment/unassign-from-NIA.md deleted file mode 100644 index bfc8ca4e83..0000000000 --- a/github-actions/trigger-issue/add-preliminary-comment/unassign-from-NIA.md +++ /dev/null @@ -1,3 +0,0 @@ - - -Hi @${issueAssignee}, HfLA appreciates your interest in this issue, but please note that it is in the `New Issue Approval` column of the Project Board because it has not been finalized, approved or prioritized, and so it is not ready for assignment. For this reason, you have been unassigned from this issue. Please remember to assign issues only from the `Prioritized Backlog` column. The one exception to this rule is if you are writing an issue and the `Draft` label is applied.