mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 06:35:51 -06:00
Update close-old-issues.yaml
This commit is contained in:
parent
c842584cfe
commit
fc505872d2
56
.github/workflows/close-old-issues.yaml
vendored
56
.github/workflows/close-old-issues.yaml
vendored
@ -14,43 +14,39 @@ jobs:
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const octokit = github.getOctokit();
|
||||
const octokit = context.octokit;
|
||||
|
||||
// Get the repository owner and name
|
||||
const { owner, repo } = github.context.repo;
|
||||
const { owner, repo } = context.repo;
|
||||
|
||||
// Define the inactivity period (14 days)
|
||||
const inactivityPeriod = new Date();
|
||||
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
|
||||
|
||||
async function run() {
|
||||
// Get all open issues
|
||||
const issues = await octokit.issues.listForRepo({
|
||||
owner,
|
||||
repo,
|
||||
state: 'open',
|
||||
});
|
||||
// Get all open issues
|
||||
const { data: issues } = await octokit.rest.issues.listForRepo({
|
||||
owner,
|
||||
repo,
|
||||
state: 'open',
|
||||
});
|
||||
|
||||
// Close issues inactive for more than the inactivity period
|
||||
for (const issue of issues.data) {
|
||||
const lastCommentDate = issue.updated_at;
|
||||
if (new Date(lastCommentDate) < inactivityPeriod) {
|
||||
// Close the issue and add a comment
|
||||
await octokit.issues.update({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issue.number,
|
||||
state: 'closed',
|
||||
});
|
||||
// Close issues inactive for more than the inactivity period
|
||||
for (const issue of issues) {
|
||||
const lastCommentDate = issue.updated_at;
|
||||
if (new Date(lastCommentDate) < inactivityPeriod) {
|
||||
// Close the issue and add a comment
|
||||
await octokit.rest.issues.update({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issue.number,
|
||||
state: 'closed',
|
||||
});
|
||||
|
||||
await octokit.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issue.number,
|
||||
body: 'Closed due to inactivity',
|
||||
});
|
||||
}
|
||||
await octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issue.number,
|
||||
body: 'Closed due to inactivity',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
run().catch(error => console.error(error));
|
||||
}
|
Loading…
Reference in New Issue
Block a user