Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/fixed-label-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Fixed Label Handler

on:
issues:
types:
- labeled

jobs:
comment_on_fixed:
if: github.event.label.name == 'fixed'
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Gather participants
id: participants
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.issue.number;
const repo = context.repo;

// Get issue details (for author)
const issue = context.payload.issue;
const author = issue.user.login;

// Get all comments
const comments = await github.paginate(
github.rest.issues.listComments,
{ ...repo, issue_number }
);
const commenters = new Set(comments.map(c => c.user.login));
commenters.delete(author); // Don't double-mention author

// Get all reactions
const all_reactors = new Set();
for (const comment of comments) {
const reactions = await github.paginate(
github.rest.reactions.listForIssueComment,
{ ...repo, comment_id: comment.id }
);
reactions.forEach(r => all_reactors.add(r.user.login));
}
// Reactions on main issue body
const issue_reactions = await github.paginate(
github.rest.reactions.listForIssue,
{ ...repo, issue_number }
);
issue_reactions.forEach(r => all_reactors.add(r.user.login));

// Remove author/commenters from reactors to avoid duplicate mentions
all_reactors.delete(author);
commenters.forEach(u => all_reactors.delete(u));

// Combine all usernames
const all_users = [author, ...commenters, ...all_reactors];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may get bots in gathering everyone and not want to mention them...

// Filter out bot users
const isBotUser = (username) => {
  return username.endsWith('[bot]') || 
         username.includes('bot') || 
         ['dependabot', 'renovate', 'greenkeeper', 'codecov', 'coveralls'].includes(username.toLowerCase());
};

// When building the all_users array:
const all_users = [author, ...commenters, ...all_reactors].filter(user => !isBotUser(user));


if (all_users.length === 0) {
return { mentions: "" };
}

const mentions = all_users.map(u => `@${u}`).join(' ');

return { mentions };
result-encoding: string

- name: Add fixed comment
uses: actions/github-script@v7
with:
script: |
const mentions = '${{steps.participants.outputs.mentions}}';
const message = `${mentions}\n\nThis issue has been fixed! Please update to the latest versions of VS Code, C# Dev Kit, and the C# extension.`;

await github.rest.issues.createComment({
...context.repo,
issue_number: context.payload.issue.number,
body: message
});
79 changes: 79 additions & 0 deletions .github/workflows/prerelease-label-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Prerelease Label Handler

on:
issues:
types:
- labeled

jobs:
comment_on_prerelease:
if: github.event.label.name == 'prerelease'
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Gather participants
id: participants
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.issue.number;
const repo = context.repo;

// Get issue details (for author)
const issue = context.payload.issue;
const author = issue.user.login;

// Get all comments
const comments = await github.paginate(
github.rest.issues.listComments,
{ ...repo, issue_number }
);
const commenters = new Set(comments.map(c => c.user.login));
commenters.delete(author); // Don't double-mention author

// Get all reactions
const all_reactors = new Set();
for (const comment of comments) {
const reactions = await github.paginate(
github.rest.reactions.listForIssueComment,
{ ...repo, comment_id: comment.id }
);
reactions.forEach(r => all_reactors.add(r.user.login));
}
// Reactions on main issue body
const issue_reactions = await github.paginate(
github.rest.reactions.listForIssue,
{ ...repo, issue_number }
);
issue_reactions.forEach(r => all_reactors.add(r.user.login));

// Remove author/commenters from reactors to avoid duplicate mentions
all_reactors.delete(author);
commenters.forEach(u => all_reactors.delete(u));

// Combine all usernames
const all_users = [author, ...commenters, ...all_reactors];

if (all_users.length === 0) {
return { mentions: "" };
}

const mentions = all_users.map(u => `@${u}`).join(' ');

return { mentions };
result-encoding: string

- name: Add prerelease comment
uses: actions/github-script@v7
with:
script: |
const mentions = '${{steps.participants.outputs.mentions}}';
const message = `${mentions}\n\nA fix for this issue is now available in the next pre-releases of C#DK/C#. If you'd like to try out the fix, please see [these instructions](https://github.com/microsoft/vscode-dotnettools/wiki/Installing-and-updating-pre%E2%80%90release-versions-of-C%23-Dev-Kit-and-C%23-Extension) to update or try pre-release versions.`;
Copy link

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The participant gathering logic is duplicated between both workflows. Consider extracting this into a reusable action or composite action to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

await github.rest.issues.createComment({
...context.repo,
issue_number: context.payload.issue.number,
body: message
});