File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments