mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 14:45:52 -06:00
Update close-old-issues.yaml
This commit is contained in:
parent
e745d798b1
commit
31c6622926
21
.github/workflows/close-old-issues.yaml
vendored
21
.github/workflows/close-old-issues.yaml
vendored
@ -7,6 +7,8 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
close-issues:
|
close-issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
issues: write # Ensure necessary permissions for issues
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Close inactive issues
|
- name: Close inactive issues
|
||||||
@ -23,18 +25,21 @@ jobs:
|
|||||||
const inactivityPeriod = new Date();
|
const inactivityPeriod = new Date();
|
||||||
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
|
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
|
||||||
|
|
||||||
// Get all open issues
|
try {
|
||||||
const { data: issues } = await octokit.rest.issues.listForRepo({
|
// Get all open issues with pagination
|
||||||
|
for await (const response of octokit.paginate.iterator(octokit.rest.issues.listForRepo, {
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
state: 'open',
|
state: 'open',
|
||||||
});
|
})) {
|
||||||
|
const issues = response.data;
|
||||||
|
|
||||||
// Close issues inactive for more than the inactivity period
|
// Close issues inactive for more than the inactivity period
|
||||||
for (const issue of issues) {
|
for (const issue of issues) {
|
||||||
const lastCommentDate = issue.updated_at;
|
const lastCommentDate = issue.updated_at;
|
||||||
if (new Date(lastCommentDate) < inactivityPeriod) {
|
if (new Date(lastCommentDate) < inactivityPeriod) {
|
||||||
// Close the issue and add a comment
|
try {
|
||||||
|
// Close the issue
|
||||||
await octokit.rest.issues.update({
|
await octokit.rest.issues.update({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
@ -42,11 +47,19 @@ jobs:
|
|||||||
state: 'closed',
|
state: 'closed',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Add a comment
|
||||||
await octokit.rest.issues.createComment({
|
await octokit.rest.issues.createComment({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
body: 'Closed due to inactivity',
|
body: 'Closed due to inactivity',
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error updating or commenting on issue #${issue.number}: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error fetching issues: ${error}`);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user