-
Notifications
You must be signed in to change notification settings - Fork 247
feat(examples): add automated issue cleanup workflow #498
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
Open
cocosheng-g
wants to merge
32
commits into
main
Choose a base branch
from
feat/issue-cleanup-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
562defc
feat(examples): add automated issue cleanup workflow
cocosheng-g 69bd8f0
fix(lint): YAML quoting in issue cleanup workflow
cocosheng-g a416cf5
feat(examples): optimize issue cleanup prompt for efficiency
cocosheng-g 0d94b4b
feat(examples): instruct agent to explicitly clone the target repository
cocosheng-g 0eedc99
fix(examples): apply PR review suggestions for issue cleanup workflow
cocosheng-g 298d9d6
feat(examples): allow custom instructions for issue cleanup triage su…
cocosheng-g cf62bef
feat(examples): support fallback to standard triage summary if custom…
cocosheng-g 1cdeb18
feat(examples): add staleness check and optimize cleanup bot
cocosheng-g 225eca7
feat(examples): separate staleness check from agent via github-script
cocosheng-g 6cee6e8
feat(examples): support explicit maintainers input for staleness check
cocosheng-g 3652158
fix(examples): fix YAML syntax error for MAINTAINERS environment vari…
cocosheng-g d572273
feat(examples): enable AI to write and execute reproduction scripts t…
cocosheng-g d0904f5
feat(examples): add 1-month age check for issue cleanup
cocosheng-g 2b10d1f
feat(examples): ask for detailed reproduction steps in 1-month age check
cocosheng-g 55bf172
feat(examples): move 1-month age check to native github-script step
cocosheng-g 67c9554
fix(examples): expand staleness maintainer check to include repositor…
cocosheng-g 7892be4
feat(examples): update issue labels during staleness and inactivity c…
cocosheng-g fa2f699
fix(examples): only update labels when asking for repro, not when clo…
cocosheng-g 7817cb2
feat(examples): close issue when asking for repro after 1 month inact…
cocosheng-g 0345f07
feat(examples): instruct reporter to reopen issue if reproducible in …
cocosheng-g d966b7f
feat(examples): close stale and inactive issues as 'not planned'
cocosheng-g fc993bb
fix(examples): quote 'on' in workflow yaml to satisfy yamllint truthy…
cocosheng-g a5f1f4e
feat(examples): exempt P0/P1 issues from auto-closing and tag assignees
cocosheng-g d1c7784
feat(examples): customize 30-day inactivity comment for feature requests
cocosheng-g 8867a8c
feat(examples): skip triage for issues tracked by epics or projects
cocosheng-g afec57e
feat(examples): ask reporter for clarification on unassigned feature …
cocosheng-g 017c077
feat(examples): ask for repro on tracked non-feature issues with no a…
cocosheng-g 3d7b3cd
feat(examples): check for resolved comments before asking for repro, …
cocosheng-g 7b58e43
feat(examples): let AI agent analyze comments to identify resolved is…
cocosheng-g b5e9a4f
feat(examples): refactor triage prompt to action-first syntax to stop…
cocosheng-g 399fae8
fix(examples): force triage bot to serialize setup operations and blo…
cocosheng-g ced7de3
feat(workflows): refactor issue cleanup to use single source of truth…
cocosheng-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
| # Issue Cleanup Workflow | ||
|
|
||
| This document describes a workflow to batch-process and clean up older open issues using Gemini CLI. | ||
|
|
||
| ## Overview | ||
|
|
||
| The Issue Cleanup workflow is designed to automate the triage of stale issues by using the Gemini CLI to: | ||
|
|
||
| 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. | ||
| 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. | ||
| 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). | ||
|
|
||
| ## Usage | ||
|
|
||
| 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. | ||
|
|
||
| To adapt this to your own repository: | ||
|
|
||
| 1. Copy `gemini-issue-cleanup.yml` to your repository's `.github/workflows/` directory. | ||
| 2. Update the repository name and search string in the `Find old issues for cleanup` step in `gemini-issue-cleanup.yml`. | ||
| 3. Update the repository name in the `Checkout Target Repository Code` step in `gemini-issue-cleanup.yml`. | ||
| 4. Copy `gemini-issue-cleanup.toml` to your `.github/commands/` directory. | ||
| 5. Update the prompt instructions in `gemini-issue-cleanup.toml` replacing `google-gemini/gemini-cli` with your repository name. |
35 changes: 35 additions & 0 deletions
35
examples/workflows/issue-cleanup/gemini-issue-cleanup.toml
This file contains hidden or 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,35 @@ | ||
| description = "Analyzes and cleans up older issues by checking code validity, duplicates, and providing a triage summary." | ||
| prompt = """ | ||
| ## Role | ||
| You are an expert AI triage assistant and repository maintainer for the `google-gemini/gemini-cli` repository. | ||
|
|
||
| ## Task | ||
| Your task is to analyze GitHub Issue #!{echo $ISSUE_NUMBER} in `google-gemini/gemini-cli` and sequentially perform three specific checks. | ||
| 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. | ||
|
|
||
| ### Step 1: Check Code Validity | ||
| - Use `gh issue view !{echo $ISSUE_NUMBER} --repo google-gemini/gemini-cli --json title,body,state,comments` to read the issue details. | ||
| - Search the local workspace (which contains the latest `google-gemini/gemini-cli` code) to determine if the issue is still valid. | ||
| - For example, if it's a bug, does the buggy code still exist? If it's a feature request, has it already been implemented? | ||
| - If you definitively determine the issue is NO LONGER VALID: | ||
| - 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>"). | ||
| - 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` | ||
| - STOP execution. You are done with this issue. | ||
|
|
||
| ### Step 2: Check for Duplicates | ||
| - If the issue is still valid, check if it's a duplicate of another issue that is already being tracked or worked on. | ||
| - Use `gh issue list --search "<keywords>" --repo google-gemini/gemini-cli --state all` with relevant keywords to find potential duplicates. | ||
| - If you find a clear duplicate that someone is working on or has already resolved: | ||
| - Close the issue as not planned, pointing to the duplicate. | ||
| - Use `gh issue close !{echo $ISSUE_NUMBER} --reason "not planned" --comment "Closing as duplicate of #<duplicate_number>." --repo google-gemini/gemini-cli` | ||
| - STOP execution. You are done with this issue. | ||
|
|
||
| ### Step 3: Provide Triage Summary | ||
| - If the issue is still valid and NOT a duplicate, add a brief summary comment for further triaging. | ||
| - State whether the issue should be categorized as: | ||
| - **Maintainer-only**: (e.g., epic, core architecture, sensitive fixes, internal tasks) | ||
| - **Help-wanted**: (e.g., good for community, general bugs, features, or tasks ready for external help) | ||
| - Your comment should be brief and clearly explain *why* it fits that category. | ||
| - 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` | ||
| - STOP execution. You are done with this issue. | ||
| """ | ||
This file contains hidden or 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,96 @@ | ||
| name: '🧹 Gemini Issue Cleanup' | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: '0 0 * * 0' # Runs weekly at midnight on Sunday | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: '${{ github.workflow }}' | ||
| cancel-in-progress: true | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: 'bash' | ||
|
|
||
| jobs: | ||
| find-issues: | ||
| runs-on: 'ubuntu-latest' | ||
| outputs: | ||
| issue_numbers: '${{ steps.find_issues.outputs.issue_numbers }}' | ||
| steps: | ||
| - name: 'Find old issues for cleanup' | ||
| id: 'find_issues' | ||
| env: | ||
| GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}' | ||
| run: |- | ||
| echo '🔍 Finding old issues for cleanup...' | ||
| # Query matches target: google-gemini/gemini-cli, open issues, sorted by oldest last update time | ||
| # with labels area/core, area/extensions, area/site, area/non-interactive | ||
| ISSUES="$(gh issue list \ | ||
| --repo google-gemini/gemini-cli \ | ||
|
cocosheng-g marked this conversation as resolved.
Outdated
|
||
| --state 'open' \ | ||
| --search "label:area/core,area/extensions,area/site,area/non-interactive sort:updated-asc" \ | ||
| --json number \ | ||
| --limit 10 \ | ||
| )" | ||
|
|
||
| # Convert to JSON array of integers | ||
| ISSUE_NUMBERS="$(echo "${ISSUES}" | jq -c '[.[].number | tostring]')" | ||
|
cocosheng-g marked this conversation as resolved.
Outdated
|
||
|
|
||
| if [ "${ISSUE_NUMBERS}" = "[]" ] || [ -z "${ISSUE_NUMBERS}" ]; then | ||
| echo "issue_numbers=[]" >> "${GITHUB_OUTPUT}" | ||
| echo "✅ No issues found to clean up." | ||
| else | ||
| echo "issue_numbers=${ISSUE_NUMBERS}" >> "${GITHUB_OUTPUT}" | ||
| echo "✅ Found $(echo "${ISSUES}" | jq 'length') issue(s) to process." | ||
| fi | ||
|
|
||
| process-issue: | ||
| needs: 'find-issues' | ||
| if: |- | ||
| needs.find-issues.outputs.issue_numbers != '[]' && needs.find-issues.outputs.issue_numbers != '' | ||
| runs-on: 'ubuntu-latest' | ||
| strategy: | ||
| matrix: | ||
| issue_number: '${{ fromJSON(needs.find-issues.outputs.issue_numbers) }}' | ||
| max-parallel: 3 | ||
| fail-fast: false | ||
| permissions: | ||
| contents: 'read' | ||
| id-token: 'write' | ||
| issues: 'write' | ||
| steps: | ||
| - name: 'Checkout Target Repository Code' | ||
| uses: 'actions/checkout@v4' | ||
| with: | ||
|
cocosheng-g marked this conversation as resolved.
|
||
| repository: 'google-gemini/gemini-cli' | ||
|
|
||
| - name: 'Run Gemini Issue Cleanup' | ||
| uses: 'google-github-actions/run-gemini-cli@v0' # Replace with actual version when deploying | ||
| env: | ||
| ISSUE_NUMBER: '${{ matrix.issue_number }}' | ||
| GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN || github.token }}' | ||
| with: | ||
| # Modify the auth settings depending on your environment | ||
| gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}' | ||
| gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}' | ||
| gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}' | ||
| gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}' | ||
| gemini_api_key: '${{ secrets.GEMINI_API_KEY }}' | ||
| workflow_name: 'gemini-issue-cleanup' | ||
| # Passing issue number to let the agent retrieve it | ||
| settings: |- | ||
| { | ||
| "model": { | ||
| "maxSessionTurns": 50 | ||
| }, | ||
| "tools": { | ||
| "core": [ | ||
| "grep_search", | ||
| "read_file", | ||
| "run_shell_command(gh)" | ||
| ] | ||
| } | ||
| } | ||
| prompt: '/gemini-issue-cleanup' | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.