Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(actions): add action to close issues without enough information #11617

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/scripts/closeNeedMoreInfoIssues.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// @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.`);

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));

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.");
};
1 change: 1 addition & 0 deletions .github/scripts/support/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const resources = {
planning: {
needsTriage: "needs triage",
needsMilestone: "needs milestone",
needsInfo: "needs more info",
spike: "spike",
spikeComplete: "spike complete",
noChangelogEntry: "no changelog entry",
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/close-needs-more-info-issues.yml
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})