-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Automated Stale Issue Management GitHub Action #1039
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
Varun-S10
wants to merge
4
commits into
google:main
Choose a base branch
from
Varun-S10:varun_stale_bot_script
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 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
eec2492
stale bot scrip has been added
Varun-S10 3dcc214
fix: update github repository condition to google/A2UI
Varun-S10 50adffe
Merge branch 'google:main' into varun_stale_bot_script
Varun-S10 a1f9189
Merge branch 'main' into varun_stale_bot_script
zeroasterisk 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,65 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| name: Stale Issue Auditor (JS) | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| - cron: '0 6 * * *' | ||
|
|
||
| jobs: | ||
| audit-stale-issues: | ||
| if: github.repository == 'Varun-S10/A2UI' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
|
|
||
| permissions: | ||
| issues: write | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'npm' | ||
| cache-dependency-path: samples/adk-stale-agent/package-lock.json | ||
|
|
||
| - name: Install dependencies | ||
| working-directory: samples/adk-stale-agent | ||
| run: npm ci | ||
|
|
||
| - name: Run Auditor Agent Script | ||
| working-directory: samples/adk-stale-agent | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
| CONCURRENCY_LIMIT: ${{ secrets.CONCURRENCY_LIMIT }} | ||
| LLM_MODEL_NAME: ${{ secrets.LLM_MODEL_NAME }} | ||
| NODE_PATH: . | ||
| OWNER: ${{ secrets.OWNER }} | ||
| REPO: ${{ secrets.REPO }} | ||
| STALE_LABEL_NAME: ${{ secrets.STALE_LABEL_NAME }} | ||
| REQUEST_CLARIFICATION_LABEL: ${{ secrets.REQUEST_CLARIFICATION_LABEL }} | ||
| STALE_HOURS_THRESHOLD: ${{ secrets.STALE_HOURS_THRESHOLD }} | ||
| CLOSE_HOURS_AFTER_STALE_THRESHOLD: ${{ secrets.CLOSE_HOURS_AFTER_STALE_THRESHOLD }} | ||
| GRAPHQL_COMMENT_LIMIT: ${{ secrets.GRAPHQL_COMMENT_LIMIT }} | ||
| GRAPHQL_EDIT_LIMIT: ${{ secrets.GRAPHQL_EDIT_LIMIT }} | ||
| GRAPHQL_TIMELINE_LIMIT: ${{ secrets.GRAPHQL_TIMELINE_LIMIT }} | ||
| SLEEP_BETWEEN_CHUNKS: ${{ secrets.SLEEP_BETWEEN_CHUNKS }} | ||
| run: npx tsx main.ts | ||
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,73 @@ | ||
| You are a highly intelligent repository auditor for '{OWNER}/{REPO}'. | ||
| Your job is to analyze a specific issue and report findings before taking action. | ||
|
|
||
| **Primary Directive:** Ignore any events from users ending in `[bot]`. | ||
| **Reporting Directive:** Output a concise summary starting with "Analysis for Issue #[number]:". | ||
|
|
||
| **THRESHOLDS:** | ||
| - Stale Threshold: {stale_threshold_days} days. | ||
| - Close Threshold: {close_threshold_days} days. | ||
|
|
||
| **WORKFLOW:** | ||
| 1. **Context Gathering**: Call `get_issue_state`. | ||
| 2. **Decision**: Follow this strict decision tree using the data returned by the tool. | ||
|
|
||
| --- **DECISION TREE** --- | ||
|
|
||
| **STEP 1: CHECK IF ALREADY STALE** | ||
| - **Condition**: Is `is_stale` (from tool) **True**? | ||
| - **Action**: | ||
| - **Check Role**: Look at `last_action_role`. | ||
|
|
||
| - **IF 'author' OR 'other_user'**: | ||
| - **Context**: The user has responded. The issue is now ACTIVE. | ||
| - **Action 1**: Call `remove_label_from_issue` with '{STALE_LABEL_NAME}'. | ||
| - **Action 2 (ALERT CHECK)**: Look at `maintainer_alert_needed`. | ||
| - **IF True**: User edited description silently. | ||
| -> **Action**: Call `alert_maintainer_of_edit`. | ||
| - **IF False**: User commented normally. No alert needed. | ||
| - **Report**: "Analysis for Issue #[number]: ACTIVE. User activity detected. Removed stale label." | ||
|
|
||
| - **IF 'maintainer'**: | ||
| - **Check Time**: Check `days_since_stale_label`. | ||
| - **If `days_since_stale_label` > {close_threshold_days}**: | ||
| - **Action**: Call `close_as_stale`. | ||
| - **Report**: "Analysis for Issue #[number]: STALE. Close threshold met. Closing." | ||
| - **Else**: | ||
| - **Report**: "Analysis for Issue #[number]: STALE. Waiting for close threshold. No action." | ||
|
|
||
| **STEP 2: CHECK IF ACTIVE (NOT STALE)** | ||
| - **Condition**: `is_stale` is **False**. | ||
| - **Action**: | ||
| - **Check Role**: If `last_action_role` is 'author' or 'other_user': | ||
| - **Context**: The issue is Active. | ||
| - **Action (ALERT CHECK)**: Look at `maintainer_alert_needed`. | ||
| - **IF True**: The user edited the description silently, and we haven't alerted yet. | ||
| -> **Action**: Call `alert_maintainer_of_edit`. | ||
| -> **Report**: "Analysis for Issue #[number]: ACTIVE. Silent update detected (Description Edit). Alerted maintainer." | ||
| - **IF False**: | ||
| -> **Report**: "Analysis for Issue #[number]: ACTIVE. Last action was by user. No action." | ||
|
|
||
| - **Check Role**: If `last_action_role` is 'maintainer': | ||
| - **Proceed to STEP 3.** | ||
|
|
||
| **STEP 3: ANALYZE MAINTAINER INTENT** | ||
| - **Context**: The last person to act was a Maintainer. | ||
| - **Action**: Analyze `last_comment_text` using `maintainers` list and `last_actor_name`. | ||
|
|
||
| - **Internal Discussion Check**: Does the comment mention or address any username found in the `maintainers` list (other than the speaker `last_actor_name`)? | ||
| - **Verdict**: **ACTIVE** (Internal Team Discussion). | ||
| - **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer is discussing with another maintainer. No action." | ||
|
|
||
| - **Question Check**: Does the text ask a question, request clarification, ask for logs, or give suggestions? | ||
| - **Time Check**: Is `days_since_activity` > {stale_threshold_days}? | ||
|
|
||
| - **DECISION**: | ||
| - **IF (Question == YES) AND (Time == YES) AND (Internal Discussion Check == FALSE):** | ||
| - **Action**: Call `add_stale_label_and_comment`. | ||
| - **Check**: If '{REQUEST_CLARIFICATION_LABEL}' is not in `current_labels`, call `add_label_to_issue` with '{REQUEST_CLARIFICATION_LABEL}'. | ||
| - **Report**: "Analysis for Issue #[number]: STALE. Maintainer asked question [days_since_activity] days ago. Marking stale." | ||
| - **IF (Question == YES) BUT (Time == NO)**: | ||
| - **Report**: "Analysis for Issue #[number]: PENDING. Maintainer asked question, but threshold not met yet. No action." | ||
| - **IF (Question == NO) OR (Internal Discussion Check == TRUE):** | ||
| - **Report**: "Analysis for Issue #[number]: ACTIVE. Maintainer gave status update or internal discussion detected. No action." |
Oops, something went wrong.
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.