GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ci: add issue deduplicator workflow by Wibias · Pull Request #298 · lidge-jun/opencodex

ci: add issue deduplicator workflow #298

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.

Sign up for GitHub

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
lidge-jun merged 5 commits into lidge-jun:dev from Wibias:feat/issue-deduplicator
Jul 22, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

ci: add issue deduplicator workflow #298

Changes from all commits
Commits
Show all changes
5 commits
Select commit Hold shift + click to select a range
0782a6d
ci: add issue deduplicator workflow
Wibias Jul 22, 2026
9a60ab6
ci(deduplicator): address CodeRabbit review findings
Wibias Jul 22, 2026
36cf37e
ci(deduplicator): address second round of CodeRabbit findings
Wibias Jul 22, 2026
0c97fd0
ci(deduplicator): add GH_REPO to label-removal step
Wibias Jul 22, 2026
d6ce71b
ci(deduplicator): guard against schema-invalid AI responses
Wibias Jul 22, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

178 changes: 178 additions & 0 deletions 178 .github/workflows/issue-deduplicator.yml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
name: Issue Deduplicator

on:
issues:
types:
- opened
- labeled

permissions:
issues: write
models: read

jobs:
find-similar:
name: Find similar issues
concurrency:
group: issue-deduplicator-${{ github.event.issue.number }}
cancel-in-progress: false
if: |
github.event.action == 'opened' ||
(github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate')
runs-on: ubuntu-latest
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


steps:
- name: Fetch issues and build prompt
id: build-prompt
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
run: |
set -eo pipefail

# Fetch open AND closed so the AI can surface already-answered duplicates
gh issue list --repo "$REPO" \
--json number,title,body,state \
--limit 500 \
--state all \
--search "sort:created-desc" \
| jq --arg cur "$ISSUE_NUMBER" '[
.[] | select(.number != ($cur | tonumber)) |
{ number, title, state, body: ((.body // "")[0:800]) }
]' \
> existing-issues.json

gh issue view "$ISSUE_NUMBER" --repo "$REPO" \
--json number,title,body \
| jq '{ number, title, body: ((.body // "")[0:2000]) }' \
> current-issue.json

echo "issue_count=$(jq 'length' existing-issues.json)"

# Build prompt file without heredocs (avoids YAML/bash indentation conflict)
{
printf 'New issue (JSON):\n'
cat current-issue.json
printf '\n\nExisting issues — open and closed (JSON array):\n'
cat existing-issues.json
printf '\n\nReturn a JSON object with this exact shape and nothing else:\n'
printf '{"issues": ["<number>", ...], "reason": "<one sentence>"}\n'
printf '\nList only issue numbers (as strings) that describe the same underlying\n'
printf 'problem or request as the new issue. Closed issues are valid matches if\n'
printf 'they already answer or resolve it. At most five. Empty array if no\n'
printf 'convincing matches exist.\n'
} > dedup-prompt.txt

- name: Run semantic duplicate detection
id: ai
uses: actions/ai-inference@b81b2afb8390ee6839b494a404766bef6493c7d9 # v1
with:
model: openai/gpt-4o-mini
max-completion-tokens: 200
system-prompt: >
You are a GitHub issue triage assistant. Identify duplicate issues
based on semantic similarity — same underlying problem, error, or
feature request — not just shared keywords. Closed issues are valid
matches if they already answer or resolve the new one. Respond only
with the requested JSON. No markdown, no explanation outside the JSON.
prompt-file: dedup-prompt.txt
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


- name: Post duplicate comment
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

env:
AI_RESPONSE: ${{ steps.ai.outputs.response }}
with:
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
const issue = context.payload.issue;
const BOT_MARKER = "<!-- opencodex-dedup-bot -->";

// Always fetch existing bot comment first — needed for both paths
const comments = await github.paginate(github.rest.issues.listComments, {
owner, repo, issue_number: issue.number, per_page: 100,
});
const existing = comments.find(
c => c.user?.type === 'Bot' && c.body?.includes(BOT_MARKER),
);

const raw = process.env.AI_RESPONSE ?? '';
let parsed;
try {
const cleaned = raw.replace(/^```(?:json)?\s*/m, '').replace(/\s*```\s*$/m, '').trim();
parsed = JSON.parse(cleaned);
} catch (err) {
core.warning(`AI response was not valid JSON: ${raw}`);
return;
}

// Build a whitelist of numbers we actually fetched — guards against hallucinations
const fetched = JSON.parse(fs.readFileSync('existing-issues.json', 'utf8'));
const validNums = new Set(fetched.map(i => String(i.number)));

if (!Array.isArray(parsed?.issues)) {
core.warning(`AI response has unexpected schema (issues is not an array): ${raw}`);
return;
}

const currentNum = String(issue.number);
const matches = [...new Set(
parsed.issues
.map(String)
.filter(n => n !== currentNum && validNums.has(n))
)].slice(0, 5);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.


if (matches.length === 0) {
if (existing) {
await github.rest.issues.deleteComment({
owner, repo, comment_id: existing.id,
});
core.info(`Removed stale dedup comment on #${issue.number} — no matches on rescan.`);
} else {
core.info('No similar issues found.');
}
return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}

// Annotate closed matches so reporters know they may already have an answer
const closedNums = new Set(
fetched.filter(i => i.state === 'closed').map(i => String(i.number))
);
const list = matches
.map(n => closedNums.has(n) ? `- #${n} _(closed)_` : `- #${n}`)
.join('\n');

const body = [
BOT_MARKER,
'Potential duplicates found — please check whether your issue is already covered:',
'',
list,
'',
'_Detected automatically via GitHub Models. Closed issues may already contain an answer. Matches may not be exact._',
].join('\n');

if (existing) {
await github.rest.issues.updateComment({
owner, repo, comment_id: existing.id, body,
});
core.info(`Updated dedup comment on #${issue.number}.`);
} else {
await github.rest.issues.createComment({
owner, repo, issue_number: issue.number, body,
});
core.info(`Posted dedup comment on #${issue.number} with ${matches.length} match(es).`);
}

- name: Remove codex-deduplicate label
if: github.event.action == 'labeled' && github.event.label.name == 'codex-deduplicate'
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
# Only swallow 404 "label not found"; propagate auth/API/runner failures
output=$(gh issue edit "${{ github.event.issue.number }}" --remove-label "codex-deduplicate" 2>&1) && exit 0 || {
echo "$output" | grep -qi "could not remove label\|label.*not found\|Label.*not exist" && exit 0
echo "$output" >&2
exit 1
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.