-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tooling(actions): adds action to close issues without enough information
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// @ts-check | ||
const { | ||
labels: { planning }, | ||
} = require("./support/resources"); | ||
|
||
/** @param {import('github-script').AsyncFunctionArguments} AsyncFunctionArguments */ | ||
module.exports = async ({ github, context }) => { | ||
const { repo, owner } = context.repo; | ||
const DAYS_BEFORE_CLOSE = 14; | ||
|
||
console.log(`Checking for issues with the label: "${planning.needsInfo}" that are stale.`); | ||
|
||
// Get all issues with the specific label | ||
const { data: issues } = await github.rest.issues.listForRepo({ | ||
owner: owner, | ||
repo: repo, | ||
state: "open", | ||
labels: planning.needsInfo, | ||
per_page: 100, | ||
}); | ||
|
||
const now = new Date(); | ||
|
||
for (const issue of issues) { | ||
const lastUpdated = new Date(issue.updated_at); | ||
const daysSinceUpdate = Math.round((now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24)); | ||
|
||
//remove this later | ||
console.log(`Days since update: ${daysSinceUpdate}`); | ||
|
||
if (daysSinceUpdate >= DAYS_BEFORE_CLOSE) { | ||
console.log(`Closing issue #${issue.number} - No updates for ${Math.round(daysSinceUpdate)} days`); | ||
|
||
await github.rest.issues.createComment({ | ||
owner: owner, | ||
repo: repo, | ||
issue_number: issue.number, | ||
body: "Closing this issue due to inactivity. If this is still an issue, it can be reopened once additional information has been provided.", | ||
}); | ||
|
||
await github.rest.issues.update({ | ||
issue_number: issue.number, | ||
owner: owner, | ||
repo: repo, | ||
state: "closed", | ||
}); | ||
} | ||
} | ||
|
||
console.log("Finished checking for issues without enough information."); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Close Need More Info Issues | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 * * *" # Runs daily at midnight UTC | ||
|
||
permissions: | ||
issues: write | ||
|
||
jobs: | ||
close-needs-more-info-issues: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Close issue if more info is not provided | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const action = require('${{ github.workspace }}/.github/scripts/closeNeedMoreInfoIssues.js') | ||
await action({github, context, core}) |