Skip to content

Commit 562defc

Browse files
committed
feat(examples): add automated issue cleanup workflow
Adds a new GitHub Action workflow and Gemini CLI command configuration to automatically process open issues with specific labels. The workflow identifies the 10 issues with the oldest last update time, checks their validity against the codebase, searches for duplicates, and provides a triage summary (Maintainer-only vs Help-wanted) for further review.
1 parent 921e068 commit 562defc

3 files changed

Lines changed: 153 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Issue Cleanup Workflow
2+
3+
This document describes a workflow to batch-process and clean up older open issues using Gemini CLI.
4+
5+
## Overview
6+
7+
The Issue Cleanup workflow is designed to automate the triage of stale issues by using the Gemini CLI to:
8+
9+
1. **Check Code Validity**: Determines if an issue is still relevant against the current codebase. If the issue has already been resolved implicitly, it will close the issue with an explanation.
10+
2. **Find Duplicates**: Checks if the issue has a more recent duplicate. If a duplicate exists, it closes the issue and links to the duplicate.
11+
3. **Summarize for Triage**: If an issue is still valid and unique, it provides a summary comment categorizing it as either `Maintainer-only` (epic, sensitive, internal) or `Help-wanted` (community-friendly).
12+
13+
## Usage
14+
15+
This example is tailored to process issues in a specific repository (`google-gemini/gemini-cli`) matching specific labels (`area/core`, `area/extensions`, `area/site`, `area/non-interactive`), selecting the 10 issues with the oldest last update time.
16+
17+
To adapt this to your own repository:
18+
19+
1. Copy `gemini-issue-cleanup.yml` to your repository's `.github/workflows/` directory.
20+
2. Update the repository name and search string in the `Find old issues for cleanup` step in `gemini-issue-cleanup.yml`.
21+
3. Update the repository name in the `Checkout Target Repository Code` step in `gemini-issue-cleanup.yml`.
22+
4. Copy `gemini-issue-cleanup.toml` to your `.github/commands/` directory.
23+
5. Update the prompt instructions in `gemini-issue-cleanup.toml` replacing `google-gemini/gemini-cli` with your repository name.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
description = "Analyzes and cleans up older issues by checking code validity, duplicates, and providing a triage summary."
2+
prompt = """
3+
## Role
4+
You are an expert AI triage assistant and repository maintainer for the `google-gemini/gemini-cli` repository.
5+
6+
## Task
7+
Your task is to analyze GitHub Issue #!{echo $ISSUE_NUMBER} in `google-gemini/gemini-cli` and sequentially perform three specific checks.
8+
You MUST use your tools (like `grep_search`, `read_file`, and `run_shell_command(gh)`) to investigate the codebase and issue tracker. Do NOT guess or hallucinate.
9+
10+
### Step 1: Check Code Validity
11+
- Use `gh issue view !{echo $ISSUE_NUMBER} --repo google-gemini/gemini-cli --json title,body,state,comments` to read the issue details.
12+
- Search the local workspace (which contains the latest `google-gemini/gemini-cli` code) to determine if the issue is still valid.
13+
- For example, if it's a bug, does the buggy code still exist? If it's a feature request, has it already been implemented?
14+
- If you definitively determine the issue is NO LONGER VALID:
15+
- Close the issue and leave a brief comment explaining why (e.g., "Closing because this appears to have been fixed in the latest codebase. <explanation>").
16+
- Use `gh issue close !{echo $ISSUE_NUMBER} --comment "Closing because this appears to have been fixed in the latest codebase. <explanation>" --repo google-gemini/gemini-cli`
17+
- STOP execution. You are done with this issue.
18+
19+
### Step 2: Check for Duplicates
20+
- If the issue is still valid, check if it's a duplicate of another issue that is already being tracked or worked on.
21+
- Use `gh issue list --search "<keywords>" --repo google-gemini/gemini-cli --state all` with relevant keywords to find potential duplicates.
22+
- If you find a clear duplicate that someone is working on or has already resolved:
23+
- Close the issue as not planned, pointing to the duplicate.
24+
- Use `gh issue close !{echo $ISSUE_NUMBER} --reason "not planned" --comment "Closing as duplicate of #<duplicate_number>." --repo google-gemini/gemini-cli`
25+
- STOP execution. You are done with this issue.
26+
27+
### Step 3: Provide Triage Summary
28+
- If the issue is still valid and NOT a duplicate, add a brief summary comment for further triaging.
29+
- State whether the issue should be categorized as:
30+
- **Maintainer-only**: (e.g., epic, core architecture, sensitive fixes, internal tasks)
31+
- **Help-wanted**: (e.g., good for community, general bugs, features, or tasks ready for external help)
32+
- Your comment should be brief and clearly explain *why* it fits that category.
33+
- Use `gh issue comment !{echo $ISSUE_NUMBER} --body "### Triage Summary\n\n**Category:** <Maintainer-only OR Help-wanted>\n\n**Reasoning:** <brief explanation>" --repo google-gemini/gemini-cli`
34+
- STOP execution. You are done with this issue.
35+
"""
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: '🧹 Gemini Issue Cleanup'
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0' # Runs weekly at midnight on Sunday
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: '${{ github.workflow }}'
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: 'bash'
15+
16+
jobs:
17+
find-issues:
18+
runs-on: 'ubuntu-latest'
19+
outputs:
20+
issue_numbers: '${{ steps.find_issues.outputs.issue_numbers }}'
21+
steps:
22+
- name: 'Find old issues for cleanup'
23+
id: 'find_issues'
24+
env:
25+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}'
26+
run: |-
27+
echo '🔍 Finding old issues for cleanup...'
28+
# Query matches target: google-gemini/gemini-cli, open issues, sorted by oldest last update time
29+
# with labels area/core, area/extensions, area/site, area/non-interactive
30+
ISSUES="$(gh issue list \
31+
--repo google-gemini/gemini-cli \
32+
--state 'open' \
33+
--search "label:area/core,area/extensions,area/site,area/non-interactive sort:updated-asc" \
34+
--json number \
35+
--limit 10 \
36+
)"
37+
38+
# Convert to JSON array of integers
39+
ISSUE_NUMBERS="$(echo "${ISSUES}" | jq -c '[.[].number | tostring]')"
40+
41+
if [ "${ISSUE_NUMBERS}" = "[]" ] || [ -z "${ISSUE_NUMBERS}" ]; then
42+
echo "issue_numbers=[]" >> "${GITHUB_OUTPUT}"
43+
echo "✅ No issues found to clean up."
44+
else
45+
echo "issue_numbers=${ISSUE_NUMBERS}" >> "${GITHUB_OUTPUT}"
46+
echo "✅ Found $(echo "${ISSUES}" | jq 'length') issue(s) to process."
47+
fi
48+
49+
process-issue:
50+
needs: find-issues
51+
if: needs.find-issues.outputs.issue_numbers != '[]' && needs.find-issues.outputs.issue_numbers != ''
52+
runs-on: 'ubuntu-latest'
53+
strategy:
54+
matrix:
55+
issue_number: ${{ fromJSON(needs.find-issues.outputs.issue_numbers) }}
56+
max-parallel: 3
57+
fail-fast: false
58+
permissions:
59+
contents: 'read'
60+
id-token: 'write'
61+
issues: 'write'
62+
steps:
63+
- name: 'Checkout Target Repository Code'
64+
uses: 'actions/checkout@v4'
65+
with:
66+
repository: 'google-gemini/gemini-cli'
67+
68+
- name: 'Run Gemini Issue Cleanup'
69+
uses: 'google-github-actions/run-gemini-cli@v0' # Replace with actual version when deploying
70+
env:
71+
ISSUE_NUMBER: '${{ matrix.issue_number }}'
72+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}'
73+
with:
74+
# Modify the auth settings depending on your environment
75+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
76+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
77+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
78+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
79+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
80+
workflow_name: 'gemini-issue-cleanup'
81+
# Passing issue number to let the agent retrieve it
82+
settings: |-
83+
{
84+
"model": {
85+
"maxSessionTurns": 50
86+
},
87+
"tools": {
88+
"core": [
89+
"grep_search",
90+
"read_file",
91+
"run_shell_command(gh)"
92+
]
93+
}
94+
}
95+
prompt: '/gemini-issue-cleanup'

0 commit comments

Comments
 (0)