-
Notifications
You must be signed in to change notification settings - Fork 40
Add workflows for fixed and prerelease label handling with automated comments #2174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4ea2e33
Add workflows for fixed and prerelease label handling with automated …
claudiaregio 92eeb15
Update .github/workflows/prerelease-label-comment.yml
claudiaregio dee94bc
Update .github/workflows/fixed-label-comment.yml
claudiaregio 8d1e23f
Update fixed-label-comment.yml
claudiaregio cc8b7f7
Update prerelease-label-comment.yml
claudiaregio 8c79968
Remove fixed and prerelease label workflows; consolidate into a singl…
claudiaregio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]; | ||
|
|
||
| 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.`; | ||
claudiaregio marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| await github.rest.issues.createComment({ | ||
| ...context.repo, | ||
| issue_number: context.payload.issue.number, | ||
| body: message | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}}'; | ||
claudiaregio marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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.`; | ||
|
||
|
|
||
| await github.rest.issues.createComment({ | ||
| ...context.repo, | ||
| issue_number: context.payload.issue.number, | ||
| body: message | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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...