-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: Add automated issue triage workflow #16275
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
Copilot
wants to merge
3
commits into
develop
Choose a base branch
from
copilot/add-agent-workflow-triage-issue
base: develop
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.
+99
−0
Open
Changes from all commits
Commits
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,99 @@ | ||
| name: Issue Triage | ||
|
|
||
| on: | ||
| issues: | ||
| types: | ||
| - opened | ||
|
|
||
| permissions: | ||
| issues: write | ||
|
|
||
| jobs: | ||
| triage: | ||
| runs-on: ubuntu-24.04-arm | ||
| # Skip triage for issues opened by bots | ||
| if: ${{ github.event.issue.user.type != 'Bot' }} | ||
|
|
||
| steps: | ||
| - name: Triage Issue | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| const issue = context.payload.issue; | ||
| const title = (issue.title || '').trim(); | ||
| const body = (issue.body || '').trim(); | ||
|
|
||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const issue_number = issue.number; | ||
| const author = issue.user.login; | ||
|
|
||
| // --- Helpers --- | ||
| const addLabel = async (label) => { | ||
| await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [label] }); | ||
| }; | ||
|
|
||
| const addComment = async (commentBody) => { | ||
| await github.rest.issues.createComment({ owner, repo, issue_number, body: commentBody }); | ||
| }; | ||
|
|
||
| // --- 1. Check for empty / too-short description --- | ||
| // A meaningful issue should have a body of at least 100 characters. | ||
| const MIN_BODY_LENGTH = 100; | ||
| if (body.length < MIN_BODY_LENGTH) { | ||
| await addLabel('needs-info'); | ||
| await addComment( | ||
| `Hi @${author}, thanks for opening an issue! 👋\n\n` + | ||
| `It looks like the description is missing or too short for us to understand the problem.\n\n` + | ||
| `Could you please provide more details, such as:\n` + | ||
| `- **Steps to reproduce** the issue\n` + | ||
| `- **Expected behavior** – what should happen\n` + | ||
| `- **Actual behavior** – what actually happens\n` + | ||
| `- **Screenshots or logs** (if applicable)\n` + | ||
| `- **Environment** – browser, OS, CARE version\n\n` + | ||
| `Once you add more information we'll take another look. Thank you! 🙏` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| // --- 2. Spam / irrelevant detection --- | ||
| // Check the combined text for known spam signals. | ||
| const text = `${title} ${body}`.toLowerCase(); | ||
|
|
||
| const spamKeywords = [ | ||
| 'casino', 'slot machine', 'poker online', 'gambling', | ||
| 'buy followers', 'buy likes', 'buy subscribers', | ||
| 'crypto investment', 'bitcoin investment', 'forex trading', | ||
| 'make money fast', 'earn money online', 'work from home opportunity', | ||
| 'click here to win', 'you have been selected', 'congratulations you won', | ||
| 'weight loss', 'diet pill', 'keto gummies', | ||
| 'seo service', 'backlink', 'guest post', | ||
| 'adult content', 'xxx', 'porn', | ||
| 'whatsapp +', 'call now +', 'contact us at +', | ||
| ]; | ||
|
|
||
| const isSpamKeyword = spamKeywords.some((kw) => text.includes(kw)); | ||
|
|
||
| // Count URLs – legitimate bug reports rarely contain more than a couple of links | ||
| const urlMatches = text.match(/https?:\/\//g) || []; | ||
| const hasManyUrls = urlMatches.length > 5; | ||
|
|
||
| // A very short title combined with a body that is almost entirely URLs is suspicious | ||
| const nonUrlBody = body.replace(/https?:\/\/\S+/g, '').trim(); | ||
| const bodyIsAlmostAllUrls = nonUrlBody.length < 30 && urlMatches.length > 1; | ||
|
|
||
| if (isSpamKeyword || hasManyUrls || bodyIsAlmostAllUrls) { | ||
| await addLabel('spam'); | ||
| await addComment( | ||
| `Hi @${author}, thanks for taking the time to open an issue.\n\n` + | ||
| `After an automated review, this issue appears to be **spam or unrelated** to the CARE project.\n\n` + | ||
| `If you believe this is a mistake and your issue is genuinely related to CARE, please feel free to ` + | ||
| `open a new issue with more context about how it relates to the project.\n\n` + | ||
| `Thank you for your understanding!` | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| // --- 3. Looks like a valid issue --- | ||
| await addLabel('triaged'); | ||
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.