diff --git a/.github/workflows/ci-failure-issue.yml b/.github/workflows/ci-failure-issue.yml index 03997af4..2114154b 100644 --- a/.github/workflows/ci-failure-issue.yml +++ b/.github/workflows/ci-failure-issue.yml @@ -36,16 +36,27 @@ jobs: const branch = context.payload.workflow_run.head_branch; const title = `CI Failure: ${workflowName}`; - const { data: issues } = await github.rest.issues.listForRepo({ + const { data } = await github.rest.search.issuesAndPullRequests({ + q: `repo:${context.repo.owner}/${context.repo.repo} is:issue is:open in:title "${title}"` + }); + + if (data.items.some(i => i.title === title)) { + core.info(`Issue already exists for "${title}"`); + return; + } + + // Fallback: check recent issues in case search index is stale + const { data: recent } = await github.rest.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.repo, - labels: 'high-severity,ci', state: 'open', - per_page: 100 + sort: 'created', + direction: 'desc', + per_page: 30 }); - if (issues.some(i => i.title === title)) { - core.info(`Issue already exists for "${title}"`); + if (recent.some(i => i.title === title)) { + core.info(`Issue already exists for "${title}" (found via fallback)`); return; }