Compare commits

..

No commits in common. "f6e9028fdb3ec0439ad038571312f46c448e0ebb" and "70ec48130505b61dbdb196c09938720c21bce402" have entirely different histories.

2 changed files with 28 additions and 37 deletions

View File

@ -3,12 +3,10 @@ name: Close Inactive Issues
on: on:
schedule: schedule:
- cron: '0 0 * * *' # Run daily - cron: '0 0 * * *' # Run daily
workflow_dispatch: # This line enables manual triggering
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
@ -16,50 +14,43 @@ jobs:
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
const octokit = github; const octokit = github.getOctokit();
// Get the repository owner and name // Get the repository owner and name
const { owner, repo } = context.repo; const { owner, repo } = github.context.repo;
// Define the inactivity period (14 days) // Define the inactivity period (14 days)
const inactivityPeriod = new Date(); const inactivityPeriod = new Date();
inactivityPeriod.setDate(inactivityPeriod.getDate() - 14); inactivityPeriod.setDate(inactivityPeriod.getDate() - 14);
try { async function run() {
// Get all open issues with pagination // Get all open issues
for await (const response of octokit.paginate.iterator(octokit.rest.issues.listForRepo, { const issues = await octokit.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.data) {
const lastCommentDate = issue.updated_at; const lastCommentDate = issue.updated_at;
if (new Date(lastCommentDate) < inactivityPeriod) { if (new Date(lastCommentDate) < inactivityPeriod) {
try { // Close the issue and add a comment
// Close the issue await octokit.issues.update({
await octokit.rest.issues.update({ owner,
owner, repo,
repo, issue_number: issue.number,
issue_number: issue.number, state: 'closed',
state: 'closed', });
});
// Add a comment await octokit.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}`);
} }
run().catch(error => console.error(error));

View File

@ -10,7 +10,7 @@
Author : Chris Titus @christitustech Author : Chris Titus @christitustech
Runspace Author: @DeveloperDurp Runspace Author: @DeveloperDurp
GitHub : https://github.com/ChrisTitusTech GitHub : https://github.com/ChrisTitusTech
Version : 24.02.21 Version : 24.02.12
#> #>
param ( param (
[switch]$Debug, [switch]$Debug,
@ -47,7 +47,7 @@ Add-Type -AssemblyName System.Windows.Forms
# Variable to sync between runspaces # Variable to sync between runspaces
$sync = [Hashtable]::Synchronized(@{}) $sync = [Hashtable]::Synchronized(@{})
$sync.PSScriptRoot = $PSScriptRoot $sync.PSScriptRoot = $PSScriptRoot
$sync.version = "24.02.21" $sync.version = "24.02.12"
$sync.configs = @{} $sync.configs = @{}
$sync.ProcessRunning = $false $sync.ProcessRunning = $false