Skip to content

Commit

Permalink
Update Github Actions Auto Close Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
og-mrk committed Apr 3, 2024
1 parent 2ee10b5 commit 41811a5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/close-old-issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
const inactivityPeriod = new Date();
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
const labelKeepIssue = 'Keep Issue Open';
try {
// Get all open issues with pagination
for await (const response of octokit.paginate.iterator(octokit.rest.issues.listForRepo, {
Expand All @@ -36,6 +37,28 @@ jobs:
// Close issues inactive for more than the inactivity period
for (const issue of issues) {
const respondIssueLabels = await octokit.request("GET /repos/{owner}/{repo}/issues/{issue_number}/labels", {
owner: owner,
repo: repo,
issue_number: issue.number
});
const closeIssue = true;
// Get all Labels of issue, and compared each label with the labelKeepIssue const variable
const labels = respondIssueLabels.data;
console.log(`${JSON.stringify(labels, null, 4)}`);
for (let i = 0; i < labels.length; i++) {
//console.log(`${JSON.stringify(labels[i], null, 4)}`);
const label = labels[i]
if (label.name === labelKeepIssue) {
console.log(`Issue #${issue.number} will not be closed`);
closeIssue = false;
}
}
if (!closeIssue) {
continue;
}
console.log('Hello');
const lastCommentDate = issue.updated_at;
if (new Date(lastCommentDate) < inactivityPeriod) {
try {
Expand Down

0 comments on commit 41811a5

Please sign in to comment.