Skip to content

Commit e936f93

Browse files
authored
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 😄
1 parent 329a35e commit e936f93

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Label Discussions
2+
3+
on:
4+
discussion:
5+
types:
6+
- created
7+
8+
jobs:
9+
label_discussions:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
discussions: write
13+
env:
14+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
16+
steps:
17+
- name: Always add "triage" label
18+
if: >
19+
github.event.discussion.node_id != '' &&
20+
(github.event.discussion.category.name == 'General' ||
21+
github.event.discussion.category.name == 'Ideas' ||
22+
github.event.discussion.category.name == 'Q&A')
23+
uses: octokit/[email protected]
24+
with:
25+
query: |
26+
mutation($labelableId: ID!) {
27+
addLabelsToLabelable(
28+
input: {
29+
labelableId: $labelableId
30+
labelIds: ["LA_kwDOJDJ_Yc8AAAABU2klmQ"]
31+
}
32+
) {
33+
clientMutationId
34+
}
35+
}
36+
variables: |
37+
{
38+
"labelableId": "${{ github.event.discussion.node_id }}"
39+
}
40+
41+
- name: Conditionally add "python" label
42+
if: >
43+
github.event.discussion.node_id != '' &&
44+
(github.event.discussion.category.name == 'General' ||
45+
github.event.discussion.category.name == 'Ideas' ||
46+
github.event.discussion.category.name == 'Q&A') &&
47+
(contains(github.event.discussion.body, 'python') ||
48+
contains(github.event.discussion.body, 'Python') ||
49+
contains(github.event.discussion.title, 'python') ||
50+
contains(github.event.discussion.title, 'Python'))
51+
uses: octokit/[email protected]
52+
with:
53+
query: |
54+
mutation($labelableId: ID!) {
55+
addLabelsToLabelable(
56+
input: {
57+
labelableId: $labelableId
58+
labelIds: ["LA_kwDOJDJ_Yc8AAAABO0f2Lg"]
59+
}
60+
) {
61+
clientMutationId
62+
}
63+
}
64+
variables: |
65+
{
66+
"labelableId": "${{ github.event.discussion.node_id }}"
67+
}
68+
69+
- name: Conditionally add ".NET" label
70+
if: >
71+
github.event.discussion.node_id != '' &&
72+
(github.event.discussion.category.name == 'General' ||
73+
github.event.discussion.category.name == 'Ideas' ||
74+
github.event.discussion.category.name == 'Q&A') &&
75+
(contains(github.event.discussion.body, '.net') ||
76+
contains(github.event.discussion.body, '.NET') ||
77+
contains(github.event.discussion.title, '.net') ||
78+
contains(github.event.discussion.title, '.NET') ||
79+
contains(github.event.discussion.body, 'dotnet') ||
80+
contains(github.event.discussion.body, 'DotNet') ||
81+
contains(github.event.discussion.title, 'dotnet') ||
82+
contains(github.event.discussion.title, 'DotNet') ||
83+
contains(github.event.discussion.body, 'c#') ||
84+
contains(github.event.discussion.body, 'C#') ||
85+
contains(github.event.discussion.title, 'c#') ||
86+
contains(github.event.discussion.title, 'C#') ||
87+
contains(github.event.discussion.body, 'csharp') ||
88+
contains(github.event.discussion.body, 'CSharp') ||
89+
contains(github.event.discussion.title, 'csharp') ||
90+
contains(github.event.discussion.title, 'CSharp'))
91+
uses: octokit/[email protected]
92+
with:
93+
query: |
94+
mutation($labelableId: ID!) {
95+
addLabelsToLabelable(
96+
input: {
97+
labelableId: $labelableId
98+
labelIds: ["LA_kwDOJDJ_Yc8AAAABN_r7Lw"]
99+
}
100+
) {
101+
clientMutationId
102+
}
103+
}
104+
variables: |
105+
{
106+
"labelableId": "${{ github.event.discussion.node_id }}"
107+
}

0 commit comments

Comments
 (0)