Skip to content

Conversation

@dmitriyastapov
Copy link

@dmitriyastapov dmitriyastapov commented Dec 12, 2025


Description of Change

This PR introduces a GitHub Action workflow that helps manage stale issues in the repository.
The bot runs daily and performs the following tasks:

  • Skips pull requests and issues labeled as to-be-discussed
  • Automatically closes issues labeled awaiting-response or those without assignees after 90+ days of inactivity
  • Sends a reminder comment on assigned issues that have been inactive for over 90 days (without re-sending it more than once a week)
  • Avoids duplicate comments and respects special labels
  • Marks type 'question' issues as 'Move to Discussion'

Added a dry-run mode that lets you preview all actions without making any changes, to run it write "1" in the "Run workflow" input filed

Test Scenarios

The script and workflow were tested on GitHub Issues in my own fork.

Related links

Testing forked repo

(eg. Closes #number of issue)

@CLAassistant
Copy link

CLAassistant commented Dec 12, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Messages
📖 🎉 Good Job! All checks are passing!

👋 Hello dmitriyastapov, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against b8e3c9b

@lucasssvaz lucasssvaz added Type: CI & Testing Related to continuous integration, automated testing, or test infrastructure. Status: Review needed Issue or PR is awaiting review labels Dec 12, 2025
@lucasssvaz lucasssvaz requested a review from Copilot December 12, 2025 17:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an automated GitHub Actions workflow to manage stale issues in the repository. The bot runs daily at 4 AM UTC and can also be triggered manually with an optional dry-run mode for testing. It processes open issues based on inactivity (90+ days) and applies different actions depending on issue status, labels, and assignment.

Key changes:

  • Automated closure of unassigned or "awaiting-response" issues after 90+ days of inactivity
  • Friendly reminder comments to assignees on inactive but assigned issues
  • Automatic labeling of question-type issues for migration to GitHub Discussions

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
.github/workflows/backlog-bot.yml GitHub Actions workflow that schedules daily runs at 4 AM UTC with manual trigger support and dry-run capability
.github/scripts/backlog-cleanup.js Core logic implementing issue triage, closure, reminder, and discussion migration behaviors with pagination support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dmitriyastapov dmitriyastapov force-pushed the master branch 2 times, most recently from 3471a58 to 9dd9b95 Compare December 15, 2025 11:01
Copy link
Member

@lucasssvaz lucasssvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some logging improvements and optimizations. Also added missing labels that should be exempt. PTAL if you agree with the changes and double check everything is working as expected. @Parsaabasi If there is anything you would like to change please let me know.

module.exports = async ({ github, context, dryRun }) => {
const now = new Date();
const thresholdDays = 90;
const exemptLabels = ['Status: Community help needed', 'Status: Needs investigation'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing some labels that should also be skipped.

Suggested change
const exemptLabels = ['Status: Community help needed', 'Status: Needs investigation'];
const exemptLabels = [
'Status: Community help needed',
'Status: Needs investigation',
'Move to Discussion',
'Status: Blocked upstream 🛑',
'Status: Blocked by ESP-IDF 🛑'
];

Comment on lines +211 to +213
- Please provide a status update
- Add any blocking details
- Or label it 'Status: Awaiting Response' if you're waiting on something
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Please provide a status update
- Add any blocking details
- Or label it 'Status: Awaiting Response' if you're waiting on something
- Please provide a status update
- Add any blocking details and labels
- Or label it 'Status: Awaiting Response' if you're waiting on the user's response

Comment on lines +1 to +15
/**
* GitHub Action script for managing issue backlog.
*
* Behavior:
* - Pull Requests are skipped (only opened issues are processed)
* - Skips issues with 'to-be-discussed' label.
* - Closes issues with label 'awaiting-response' or without assignees,
* with a standard closure comment.
* - Sends a Friendly Reminder comment to assigned issues without
* exempt labels that have been inactive for 90+ days.
* - Avoids sending duplicate Friendly Reminder comments if one was
* posted within the last 7 days.
* - Marks issues labeled 'questions' by adding the 'Move to Discussion' label.
* (Actual migration to Discussions must be handled manually.)
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/**
* GitHub Action script for managing issue backlog.
*
* Behavior:
* - Pull Requests are skipped (only opened issues are processed)
* - Skips issues with 'to-be-discussed' label.
* - Closes issues with label 'awaiting-response' or without assignees,
* with a standard closure comment.
* - Sends a Friendly Reminder comment to assigned issues without
* exempt labels that have been inactive for 90+ days.
* - Avoids sending duplicate Friendly Reminder comments if one was
* posted within the last 7 days.
* - Marks issues labeled 'questions' by adding the 'Move to Discussion' label.
* (Actual migration to Discussions must be handled manually.)
*/
/**
* GitHub Action script for managing issue backlog.
*
* Behavior:
* - Pull Requests are skipped (only opened issues are processed)
* - Skips issues with labels defined in 'exemptLabels'
* - Closes issues with labels defined in 'closeLabels' or without assignees,
* with a standard closure comment.
* - Sends a Friendly Reminder comment to assigned issues without
* exempt labels that have been inactive for 90+ days.
* - Avoids sending duplicate Friendly Reminder comments if one was
* posted within the last 7 days.
* - Marks issues labeled 'Type: Question' by adding the 'Move to Discussion' label.
* (Actual migration to Discussions must be handled manually due to API limitations.)
*/

for (const issue of issues) {
const isAssigned = issue.assignees && issue.assignees.length > 0;
const lastUpdate = new Date(issue.updated_at);
const daysSinceUpdate = Math.floor((now - lastUpdate) / (1000 * 60 * 60 * 24));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const daysSinceUpdate = Math.floor((now - lastUpdate) / (1000 * 60 * 60 * 24));
const oneDayMs = 1000 * 60 * 60 * 24;
const daysSinceUpdate = Math.floor((now - lastUpdate) / oneDayMs);

Comment on lines +23 to +24
const lines = result.split('\n');
const minIndent = Math.min(...lines.filter(l => l.trim()).map(l => l.match(/^\s*/)[0].length));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid using empty lines in Math.min

Suggested change
const lines = result.split('\n');
const minIndent = Math.min(...lines.filter(l => l.trim()).map(l => l.match(/^\s*/)[0].length));
const lines = result.split('\n');
if (!lines.some(l => l.trim())) return '';
const minIndent = Math.min(...lines.filter(l => l.trim()).map(l => l.match(/^\s*/)[0].length));

Comment on lines +153 to +155
if (issue.labels.some(label => exemptLabels.includes(label.name))) {
totalSkipped++;
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (issue.labels.some(label => exemptLabels.includes(label.name))) {
totalSkipped++;
continue;
if (issue.labels.some(label => exemptLabels.includes(label.name))) {
console.log(`Skipping #${issue.number} (exempt label)`);
totalSkipped++;
continue;

Comment on lines +164 to +166
if (daysSinceUpdate < thresholdDays) {
totalSkipped++;
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (daysSinceUpdate < thresholdDays) {
totalSkipped++;
continue;
if (daysSinceUpdate < thresholdDays) {
console.log(`Skipping #${issue.number} (recent activity)`);
totalSkipped++;
continue;

Comment on lines +199 to +202
if (await hasRecentFriendlyReminder(github, owner, repo, issue.number, sevenDaysMs)) {
totalSkipped++;
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (await hasRecentFriendlyReminder(github, owner, repo, issue.number, sevenDaysMs)) {
totalSkipped++;
continue;
}
if (await hasRecentFriendlyReminder(github, owner, repo, issue.number, sevenDaysMs)) {
console.log(`Skipping #${issue.number} (recent reminder)`);
totalSkipped++;
continue;
}

Comment on lines +177 to +178
try {
await github.rest.issues.createComment({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try {
await github.rest.issues.createComment({
try {
console.log(`Closing #${issue.number} (inactivity)`);
await github.rest.issues.createComment({

Comment on lines +43 to +44
try {
await github.rest.issues.addLabels({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try {
await github.rest.issues.addLabels({
try {
console.log(`Adding label to #${issue.number} (Move to discussion)`);
await github.rest.issues.addLabels({

@lucasssvaz lucasssvaz removed the Status: Review needed Issue or PR is awaiting review label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: CI & Testing Related to continuous integration, automated testing, or test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants