Skip to content

Commit ee8c7b6

Browse files
committed
fix: use search API with listForRepo fallback for issue dedup
1 parent d8fc802 commit ee8c7b6

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/ci-failure-issue.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,27 @@ jobs:
3636
const branch = context.payload.workflow_run.head_branch;
3737
const title = `CI Failure: ${workflowName}`;
3838
39-
const { data: issues } = await github.rest.issues.listForRepo({
39+
const { data } = await github.rest.search.issuesAndPullRequests({
40+
q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open in:title "${title}"`
41+
});
42+
43+
if (data.items.some(i => i.title === title)) {
44+
core.info(`Issue already exists for "${title}"`);
45+
return;
46+
}
47+
48+
// Fallback: check recent issues in case search index is stale
49+
const { data: recent } = await github.rest.issues.listForRepo({
4050
owner: context.repo.owner,
4151
repo: context.repo.repo,
42-
labels: 'high-severity,ci',
4352
state: 'open',
44-
per_page: 100
53+
sort: 'created',
54+
direction: 'desc',
55+
per_page: 30
4556
});
4657
47-
if (issues.some(i => i.title === title)) {
48-
core.info(`Issue already exists for "${title}"`);
58+
if (recent.some(i => i.title === title)) {
59+
core.info(`Issue already exists for "${title}" (found via fallback)`);
4960
return;
5061
}
5162

0 commit comments

Comments
 (0)