Skip to content

Commit 014b6b9

Browse files
Copilotdanroth27
andcommitted
Add concurrency control and improve duplicate detection logic
Co-authored-by: danroth27 <1874516+danroth27@users.noreply.github.com>
1 parent 2f2ba29 commit 014b6b9

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

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

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
# Only run if the issue has the "Breaking change" label
1919
if: contains(github.event.issue.labels.*.name, 'Breaking change')
20+
# Prevent concurrent runs for the same issue to avoid race conditions
21+
concurrency:
22+
group: docs-issue-${{ github.event.issue.number }}
23+
cancel-in-progress: false
2024
steps:
2125
- name: Create issue in aspnetcore.docs
2226
uses: actions/github-script@v7
@@ -32,19 +36,38 @@ jobs:
3236
const issueBody = context.payload.issue.body || '';
3337
3438
// Check if we've already created a docs issue for this breaking change
35-
// by looking for existing comments with the specific marker text
39+
// First, check for existing comments in the current issue
3640
const comments = await github.rest.issues.listComments({
3741
owner: context.repo.owner,
3842
repo: context.repo.repo,
3943
issue_number: issueNumber
4044
});
4145
42-
const docsIssueAlreadyCreated = comments.data.some(comment =>
46+
const commentExists = comments.data.some(comment =>
4347
comment.body.includes('A documentation tracking issue has been created')
4448
);
4549
46-
if (docsIssueAlreadyCreated) {
47-
console.log('Docs issue already created for this breaking change. Skipping.');
50+
if (commentExists) {
51+
console.log('Docs issue comment already exists. Skipping.');
52+
return;
53+
}
54+
55+
// Also check the docs repository for existing issues with the same title
56+
const docsIssueTitle = `[Breaking Change] ${issueTitle}`;
57+
const searchResults = await github.rest.search.issuesAndPullRequests({
58+
q: `"${docsIssueTitle}" repo:dotnet/AspNetCore.Docs is:issue`
59+
});
60+
61+
if (searchResults.data.total_count > 0) {
62+
console.log('Docs issue already exists in target repository. Skipping.');
63+
// Add comment to the original issue with link to existing docs issue if not already present
64+
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+
});
4871
return;
4972
}
5073
@@ -91,4 +114,3 @@ Please add documentation for this breaking change to the ASP.NET Core documentat
91114
throw new Error(`Failed to create docs issue: ${error.message}`);
92115
}
93116

94-

0 commit comments

Comments
 (0)