mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
52 lines
1.5 KiB
YAML
52 lines
1.5 KiB
YAML
|
name: Close Inactive Issues
|
||
|
|
||
|
on:
|
||
|
schedule:
|
||
|
- cron: '0 0 * * *' # Run daily
|
||
|
|
||
|
jobs:
|
||
|
close-issues:
|
||
|
runs-on: ubuntu-latest
|
||
|
|
||
|
steps:
|
||
|
- name: Close inactive issues
|
||
|
uses: actions/github-script@v7
|
||
|
with:
|
||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||
|
script: |
|
||
|
const octokit = context.octokit;
|
||
|
|
||
|
// Get the repository owner and name
|
||
|
const { owner, repo } = context.repo;
|
||
|
|
||
|
// Define the inactivity period (14 days)
|
||
|
const inactivityPeriod = new Date();
|
||
|
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
|
||
|
|
||
|
// 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) {
|
||
|
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.rest.issues.createComment({
|
||
|
owner,
|
||
|
repo,
|
||
|
issue_number: issue.number,
|
||
|
body: 'Closed due to inactivity',
|
||
|
});
|
||
|
}
|
||
|
}
|