Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Github Action that handles self assigning an issue from New Issue Approval column" #6557

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}
}
}
Expand All @@ -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

This file was deleted.

Loading