Skip to content

Commit fec8b17

Browse files
Copilotdanroth27
andcommitted
Improve search robustness and error handling for fallback comments
Co-authored-by: danroth27 <[email protected]>
1 parent 014b6b9 commit fec8b17

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

.github/workflows/create-docs-issue.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,28 @@ jobs:
5353
}
5454
5555
// Also check the docs repository for existing issues with the same title
56+
// Use a more robust search that can handle special characters
5657
const docsIssueTitle = `[Breaking Change] ${issueTitle}`;
58+
const escapedTitle = docsIssueTitle.replace(/"/g, '\\"');
5759
const searchResults = await github.rest.search.issuesAndPullRequests({
58-
q: `"${docsIssueTitle}" repo:dotnet/AspNetCore.Docs is:issue`
60+
q: `"${escapedTitle}" repo:dotnet/AspNetCore.Docs is:issue in:title`
5961
});
6062
6163
if (searchResults.data.total_count > 0) {
6264
console.log('Docs issue already exists in target repository. Skipping.');
6365
// Add comment to the original issue with link to existing docs issue if not already present
6466
const existingDocsIssue = searchResults.data.items[0];
65-
await github.rest.issues.createComment({
66-
owner: context.repo.owner,
67-
repo: context.repo.repo,
68-
issue_number: issueNumber,
69-
body: `📝 A documentation tracking issue has been created: ${existingDocsIssue.html_url}`
70-
});
67+
try {
68+
await github.rest.issues.createComment({
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
issue_number: issueNumber,
72+
body: `📝 A documentation tracking issue has been created: ${existingDocsIssue.html_url}`
73+
});
74+
} catch (commentError) {
75+
console.error('Failed to post comment about existing docs issue:', commentError);
76+
// Don't fail the workflow if we can't post the comment
77+
}
7178
return;
7279
}
7380
@@ -113,4 +120,3 @@ Please add documentation for this breaking change to the ASP.NET Core documentat
113120
}
114121
throw new Error(`Failed to create docs issue: ${error.message}`);
115122
}
116-

0 commit comments

Comments
 (0)