Skip to content

Commit 8b0021e

Browse files
Merge pull request #3580 from MicrosoftDocs/feature/pr-labeler-autogen-warning
Add PR labeler with auto-generated content warning
2 parents eb93396 + 103acea commit 8b0021e

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

.github/workflows/pr-labeler.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,39 @@ jobs:
216216
} else {
217217
console.log('No labels to apply.');
218218
}
219+
220+
// --- Post a comment if auto-generated content was edited (de-duplicated) ---
221+
if (hasDoNotEditChanges) {
222+
// Check if we already posted this warning on this PR
223+
const comments = await github.rest.issues.listComments({
224+
owner: context.repo.owner,
225+
repo: context.repo.repo,
226+
issue_number: context.issue.number,
227+
});
228+
229+
const marker = '<!-- auto-generated-edit-warning -->';
230+
const alreadyPosted = comments.data.some(c => c.body.includes(marker));
231+
232+
if (!alreadyPosted) {
233+
const body = marker + '\n' +
234+
`⚠️ **Auto-generated content edited**\n\n` +
235+
`This PR modifies content inside \`DO_NOT_EDIT\` markers. ` +
236+
`These sections are regenerated from source and your changes ` +
237+
`will be overwritten on the next refresh.\n\n` +
238+
`**What to do:**\n` +
239+
`- If you're fixing a bug in auto-generated content (syntax, description, parameters), ` +
240+
`the fix needs to go in the source \`.xml\` files in the ModernDev repo instead.\n` +
241+
`- If you're adding remarks, examples, or related information, move your content ` +
242+
`**below** the \`END>DO_NOT_EDIT\` marker where it will be preserved.\n\n` +
243+
`See the contribution guide for details on which sections are safe to edit.`;
244+
245+
await github.rest.issues.createComment({
246+
owner: context.repo.owner,
247+
repo: context.repo.repo,
248+
issue_number: context.issue.number,
249+
body: body,
250+
});
251+
}
252+
}
219253
env:
220-
BASE_REF: ${{ github.base_ref }}
254+
BASE_REF: ${{ github.base_ref }}

0 commit comments

Comments
 (0)