-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Add issue deduplicator workflow #4628
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Some comments aren't visible on the classic Files Changed page.
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,19 @@ | ||
You are an assistant that triages new GitHub issues by identifying potential duplicates. | ||
|
||
You will receive the following JSON files located in the current working directory: | ||
- `codex-current-issue.json`: JSON object describing the newly created issue (fields: number, title, body). | ||
- `codex-existing-issues.json`: JSON array of recent issues (each element includes number, title, body, createdAt). | ||
|
||
Instructions: | ||
- Load both files as JSON and review their contents carefully. | ||
- Compare the current issue against the existing issues to find up to five that appear to describe the same underlying problem or request. | ||
- Only consider an issue a potential duplicate if there is a clear overlap in symptoms, feature requests, reproduction steps, or error messages. | ||
- Prioritize newer issues when similarity is comparable. | ||
- Ignore pull requests and issues whose similarity is tenuous. | ||
- When unsure, prefer returning fewer matches. | ||
|
||
Output requirements: | ||
- Respond with a JSON array of issue numbers (integers), ordered from most likely duplicate to least. | ||
- Include at most five numbers. | ||
- If you find no plausible duplicates, respond with `[]`. | ||
- Do not emit any additional commentary, text, or keys beyond the JSON array. |
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,88 @@ | ||
name: Issue Deduplicator | ||
|
||
on: | ||
issues: | ||
types: | ||
# - opened - disabled while testing | ||
- labeled | ||
|
||
jobs: | ||
gather-duplicates: | ||
name: Identify potential duplicates | ||
if: ${{ github.event.action == 'opened' || (github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate') }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
outputs: | ||
codex_output: ${{ steps.codex.outputs.final_message }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Prepare Codex inputs | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
set -eo pipefail | ||
|
||
CURRENT_ISSUE_FILE=codex-current-issue.json | ||
EXISTING_ISSUES_FILE=codex-existing-issues.json | ||
|
||
gh issue list --repo "${{ github.repository }}" \ | ||
--json number,title,body,createdAt \ | ||
--limit 1000 \ | ||
--state all \ | ||
--search "sort:created-desc" \ | ||
| jq '.' \ | ||
> "$EXISTING_ISSUES_FILE" | ||
|
||
printf '%s' '${{ toJson(github.event.issue) }}' \ | ||
| jq '{number, title, body}' \ | ||
> "$CURRENT_ISSUE_FILE" | ||
|
||
- id: codex | ||
uses: openai/codex-action@main | ||
with: | ||
openai_api_key: ${{ secrets.CODEX_OPENAI_API_KEY }} | ||
prompt_file: .github/prompts/issue-deduplicator.txt | ||
require_repo_write: false | ||
|
||
comment-on-issue: | ||
name: Comment with potential duplicates | ||
needs: gather-duplicates | ||
if: ${{ needs.gather-duplicates.result != 'skipped' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
issues: write | ||
steps: | ||
- name: Comment on issue | ||
uses: actions/github-script@v7 | ||
env: | ||
CODEX_OUTPUT: ${{ needs.gather-duplicates.outputs.codex_output }} | ||
with: | ||
github-token: ${{ github.token }} | ||
script: | | ||
let numbers; | ||
try { | ||
numbers = JSON.parse(process.env.CODEX_OUTPUT); | ||
} catch (error) { | ||
core.info(`Codex output was not valid JSON. Raw output: ${raw}`); | ||
return; | ||
} | ||
|
||
const lines = ['Potential duplicates detected:', ...numbers.map((value) => `- #${value}`)]; | ||
|
||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.issue.number, | ||
body: lines.join("\n"), | ||
}); | ||
|
||
- name: Remove codex-deduplicate label | ||
if: ${{ always() && github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate' }} | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh issue edit "${{ github.event.issue.number }}" --remove-label codex-deduplicate || true | ||
echo "Attempted to remove label: codex-deduplicate" |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
always()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so even if the action fails the label is removed and someone can add it again to retry