Files
Evan Mattson e936f93871 Add Discussion label workflow (#11300)
### Motivation and Context

Right now, we need to manually go through each new discussion item to
figure out if it needs certain labels. We also can miss discussion items
as we don't have the "triage" label applied automatically like we do for
issues. We have some discussion categories where users can post for help
-- specifically "General," "Q&A," and "Ideas." Other discussion
categories don't warrant "triage," "python," or ".NET" labels.

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

### Description

This PR adds a "Label Discussions" workflow that runs when new
discussions are created as part of General, Ideas, or Q&A, that
leverages GitHub's GraphQL API. This was tested in my SK fork for new
issues, and it properly adds the appropriate label based on the content
of the discussion item.

This should help make sure we don't miss any discussion item as we look
through them during triage.

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [X] The code builds clean without any errors or warnings
- [X] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [X] All unit tests pass, and I have added new tests where possible
- [X] I didn't break anyone 😄
2025-04-02 23:27:02 +00:00

108 lines
3.8 KiB
YAML

name: Label Discussions
on:
discussion:
types:
- created
jobs:
label_discussions:
runs-on: ubuntu-latest
permissions:
discussions: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Always add "triage" label
if: >
github.event.discussion.node_id != '' &&
(github.event.discussion.category.name == 'General' ||
github.event.discussion.category.name == 'Ideas' ||
github.event.discussion.category.name == 'Q&A')
uses: octokit/[email protected]
with:
query: |
mutation($labelableId: ID!) {
addLabelsToLabelable(
input: {
labelableId: $labelableId
labelIds: ["LA_kwDOJDJ_Yc8AAAABU2klmQ"]
}
) {
clientMutationId
}
}
variables: |
{
"labelableId": "${{ github.event.discussion.node_id }}"
}
- name: Conditionally add "python" label
if: >
github.event.discussion.node_id != '' &&
(github.event.discussion.category.name == 'General' ||
github.event.discussion.category.name == 'Ideas' ||
github.event.discussion.category.name == 'Q&A') &&
(contains(github.event.discussion.body, 'python') ||
contains(github.event.discussion.body, 'Python') ||
contains(github.event.discussion.title, 'python') ||
contains(github.event.discussion.title, 'Python'))
uses: octokit/[email protected]
with:
query: |
mutation($labelableId: ID!) {
addLabelsToLabelable(
input: {
labelableId: $labelableId
labelIds: ["LA_kwDOJDJ_Yc8AAAABO0f2Lg"]
}
) {
clientMutationId
}
}
variables: |
{
"labelableId": "${{ github.event.discussion.node_id }}"
}
- name: Conditionally add ".NET" label
if: >
github.event.discussion.node_id != '' &&
(github.event.discussion.category.name == 'General' ||
github.event.discussion.category.name == 'Ideas' ||
github.event.discussion.category.name == 'Q&A') &&
(contains(github.event.discussion.body, '.net') ||
contains(github.event.discussion.body, '.NET') ||
contains(github.event.discussion.title, '.net') ||
contains(github.event.discussion.title, '.NET') ||
contains(github.event.discussion.body, 'dotnet') ||
contains(github.event.discussion.body, 'DotNet') ||
contains(github.event.discussion.title, 'dotnet') ||
contains(github.event.discussion.title, 'DotNet') ||
contains(github.event.discussion.body, 'c#') ||
contains(github.event.discussion.body, 'C#') ||
contains(github.event.discussion.title, 'c#') ||
contains(github.event.discussion.title, 'C#') ||
contains(github.event.discussion.body, 'csharp') ||
contains(github.event.discussion.body, 'CSharp') ||
contains(github.event.discussion.title, 'csharp') ||
contains(github.event.discussion.title, 'CSharp'))
uses: octokit/[email protected]
with:
query: |
mutation($labelableId: ID!) {
addLabelsToLabelable(
input: {
labelableId: $labelableId
labelIds: ["LA_kwDOJDJ_Yc8AAAABN_r7Lw"]
}
) {
clientMutationId
}
}
variables: |
{
"labelableId": "${{ github.event.discussion.node_id }}"
}