Skip to content

Commit 8867a8c

Browse files
committed
feat(examples): skip triage for issues tracked by epics or projects
1 parent d1c7784 commit 8867a8c

2 files changed

Lines changed: 49 additions & 5 deletions

File tree

examples/workflows/issue-cleanup/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ This document describes a workflow to batch-process and clean up older open issu
66

77
The Issue Cleanup workflow is designed to automate the triage of stale issues by using the Gemini CLI to:
88

9-
1. **Check for Staleness and Age (Native)**: Identifies if an issue has been waiting for reporter feedback for over 7 days, closing it if so. If the issue is not stale but hasn't been updated in over a month, it asks the reporter to reproduce it with the latest build. For feature requests, it asks to reopen if still needed. By default, it closes the inactive issue and tags any assignees to reopen it. However, if the issue is a high-priority (`p0` or `p1`), it leaves the issue open. This logic runs natively to save AI resources.
10-
2. **Check for Vagueness (AI)**: If an issue is not stale or old but lacks sufficient information (e.g., reproduction steps), the agent asks the reporter for specific details and stops.
11-
3. **Check Code Validity (AI)**: Determines if an issue is still relevant against the current codebase. The agent may attempt to write and execute a minimal reproduction script to verify if a bug has been resolved, or manually inspect the code. If verified as fixed, it will close the issue with an explanation.
12-
4. **Find Duplicates (AI)**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
13-
5. **Summarize for Triage (AI)**: If an issue is still valid and unique, it provides a summary comment based on customizable instructions (e.g., categorizing it as `Maintainer-only` or `Help-wanted`). If no custom instructions are provided, it falls back to a standard triage summary.
9+
1. **Check for Projects and Parent Issues (Native)**: Identifies if an issue is already part of a GitHub Project or tracked by a parent issue (task list). If so, it removes the triage label and stops, assuming the issue is already being managed as part of a larger epic.
10+
2. **Check for Staleness and Age (Native)**: Identifies if an issue has been waiting for reporter feedback for over 7 days, closing it if so. If the issue is not stale but hasn't been updated in over a month, it asks the reporter to reproduce it with the latest build. For feature requests, it asks to reopen if still needed. By default, it closes the inactive issue and tags any assignees to reopen it. However, if the issue is a high-priority (`p0` or `p1`), it leaves the issue open. This logic runs natively to save AI resources.
11+
3. **Check for Vagueness (AI)**: If an issue is not stale or old but lacks sufficient information (e.g., reproduction steps), the agent asks the reporter for specific details and stops.
12+
4. **Check Code Validity (AI)**: Determines if an issue is still relevant against the current codebase. The agent may attempt to write and execute a minimal reproduction script to verify if a bug has been resolved, or manually inspect the code. If verified as fixed, it will close the issue with an explanation.
13+
5. **Find Duplicates (AI)**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
14+
6. **Summarize for Triage (AI)**: If an issue is still valid and unique, it provides a summary comment based on customizable instructions (e.g., categorizing it as `Maintainer-only` or `Help-wanted`). If no custom instructions are provided, it falls back to a standard triage summary.
1415

1516
## Usage
1617

examples/workflows/issue-cleanup/gemini-issue-cleanup.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,49 @@ jobs:
7979
8080
const maintainers = process.env.MAINTAINERS ? process.env.MAINTAINERS.split(',').map(m => m.trim()) : [];
8181
82+
// First, check if it's tracked by a parent issue or part of a project
83+
const query = `
84+
query($owner: String!, $repo: String!, $issueNumber: Int!) {
85+
repository(owner: $owner, name: $repo) {
86+
issue(number: $issueNumber) {
87+
trackedInIssues(first: 1) {
88+
totalCount
89+
}
90+
projectItems(first: 1) {
91+
totalCount
92+
}
93+
}
94+
}
95+
}
96+
`;
97+
try {
98+
const result = await github.graphql(query, {
99+
owner: context.repo.owner,
100+
repo: context.repo.repo,
101+
issueNumber: issueNumber
102+
});
103+
const isTracked = result.repository.issue.trackedInIssues.totalCount > 0;
104+
const inProject = result.repository.issue.projectItems.totalCount > 0;
105+
106+
if (isTracked || inProject) {
107+
console.log(`Issue #${issueNumber} is tracked by a parent issue or project. Removing 'status/need-triage' and stopping.`);
108+
try {
109+
await github.rest.issues.removeLabel({
110+
owner: context.repo.owner,
111+
repo: context.repo.repo,
112+
issue_number: issueNumber,
113+
name: 'status/need-triage'
114+
});
115+
} catch (e) {
116+
// Ignore if label doesn't exist
117+
}
118+
core.setOutput('is_stale', 'true');
119+
return;
120+
}
121+
} catch (err) {
122+
console.log('Failed to fetch GraphQL data for parent issues/projects:', err.message);
123+
}
124+
82125
const { data: issue } = await github.rest.issues.get({
83126
owner: context.repo.owner,
84127
repo: context.repo.repo,

0 commit comments

Comments
 (0)