Skip to content

Commit

Permalink
Update query-issue-info.js
Browse files Browse the repository at this point in the history
  • Loading branch information
t-will-gillis authored Jul 20, 2024
1 parent eccd467 commit 28927f1
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions github-actions/utils/query-issue-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ async function queryIssueInfo(issueNum, github, context) {
repo: context.repo.repo,
issueNum: issueNum
};

/*
try {
const response = await github.graphql(query, variables);

console.log(response);
// Extract the list of project items associated with the issue
const projectItems = response.repository.issue.projectItems.nodes;

console.log(projectItems);
// Since there is always one item associated with the issue,
// directly get the item's ID from the first index
const id = projectItems[0].id;
Expand All @@ -57,6 +57,25 @@ async function queryIssueInfo(issueNum, github, context) {
} catch(error) {
throw new Error(`Error finding Issue #${issueNum} id and status; error = ${error}`);
}
*/

const response = await github.graphql(query, variables);
console.log(response);
// Extract the list of project items associated with the issue
const projectItems = response.repository.issue.projectItems.nodes;
console.log(projectItems);
// Since there is always one item associated with the issue,
// directly get the item's ID from the first index
const id = projectItems[0].id;

// Iterate through the field values of the first project item
// and find the node that contains the 'name' property, then get its 'name' value
const statusName = projectItems[0].fieldValues.nodes.find(item => item.hasOwnProperty('name')).name;
console.log(`status ${statusName}`);
// console.log(`Success! For Issue #${ISSUE_NUMBER}, found id = '${id}' and status = '${statusName}'`);
return { id, statusName };

}

module.exports = queryIssueInfo;

0 comments on commit 28927f1

Please sign in to comment.