Skip to content

Commit fc0c95b

Browse files
Copilotdanroth27
andcommitted
Add workflow to create docs tracking issues for breaking changes
Co-authored-by: danroth27 <[email protected]>
1 parent a51472c commit fc0c95b

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: "Create Docs Issue for Breaking Change"
2+
on:
3+
issues:
4+
types: [opened, labeled]
5+
6+
jobs:
7+
create-docs-issue:
8+
runs-on: ubuntu-latest
9+
# Only run if the issue has the "Breaking change" label
10+
if: contains(github.event.issue.labels.*.name, 'Breaking change')
11+
steps:
12+
- name: Create issue in aspnetcore.docs
13+
uses: actions/github-script@v7
14+
with:
15+
# Use a token with cross-repository permissions
16+
# The GITHUB_TOKEN doesn't have permission to create issues in other repos
17+
# A PAT with repo scope should be stored as a secret (e.g., DOCS_ISSUE_TOKEN)
18+
github-token: ${{ secrets.DOCS_ISSUE_TOKEN || secrets.GITHUB_TOKEN }}
19+
script: |
20+
const issueTitle = context.payload.issue.title;
21+
const issueNumber = context.payload.issue.number;
22+
const issueUrl = context.payload.issue.html_url;
23+
const issueBody = context.payload.issue.body || '';
24+
25+
// Check if we've already created a docs issue for this breaking change
26+
// by looking for existing comments from the bot
27+
const comments = await github.rest.issues.listComments({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
issue_number: issueNumber
31+
});
32+
33+
const docsIssueAlreadyCreated = comments.data.some(comment =>
34+
comment.user.type === 'Bot' &&
35+
comment.body.includes('A documentation tracking issue has been created')
36+
);
37+
38+
if (docsIssueAlreadyCreated) {
39+
console.log('Docs issue already created for this breaking change. Skipping.');
40+
return;
41+
}
42+
43+
// Create the issue body for the docs repo
44+
const docsIssueBody = `This issue tracks adding documentation for a breaking change announced in aspnet/Announcements.
45+
46+
**Breaking Change Issue:** ${issueUrl}
47+
**Issue Number:** #${issueNumber}
48+
**Title:** ${issueTitle}
49+
50+
---
51+
52+
${issueBody}
53+
54+
---
55+
56+
Please add documentation for this breaking change to the ASP.NET Core documentation.`;
57+
58+
// Create the issue in dotnet/aspnetcore.docs
59+
try {
60+
const newIssue = await github.rest.issues.create({
61+
owner: 'dotnet',
62+
repo: 'AspNetCore.Docs',
63+
title: `[Breaking Change] ${issueTitle}`,
64+
body: docsIssueBody,
65+
labels: ['breaking-change', 'aspnet/Announcements']
66+
});
67+
68+
console.log(`Created issue: ${newIssue.data.html_url}`);
69+
70+
// Comment on the original issue with a link to the docs issue
71+
await github.rest.issues.createComment({
72+
owner: context.repo.owner,
73+
repo: context.repo.repo,
74+
issue_number: issueNumber,
75+
body: `📝 A documentation tracking issue has been created: ${newIssue.data.html_url}`
76+
});
77+
} catch (error) {
78+
console.error('Error creating docs issue:', error);
79+
core.setFailed(`Failed to create docs issue: ${error.message}`);
80+
}

0 commit comments

Comments
 (0)