-
Notifications
You must be signed in to change notification settings - Fork 454
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
Add Auto-Labeling for Issues using GitHub Actions #5136
base: main
Are you sure you want to change the base?
Changes from 10 commits
796accb
bd41571
f23b433
3b7e8dc
031a601
61d3c13
baf2aec
643b48e
1024bc9
162172b
d78ace3
c18583e
363d284
b086521
fde4323
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
name: Auto Label Issues | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] # Runs when an issue is created or modified | ||
workflow_dispatch: # Allows manual triggering | ||
|
||
jobs: | ||
label: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Auto-label Issues | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const issue = context.payload.issue; | ||
const labelsToAdd = []; | ||
|
||
// Define label mappings based on brackets in title | ||
const labelMappings = { | ||
"[bug]": "bug", | ||
"[feature]": "enhancement", | ||
"[docs]": "documentation", | ||
"[dpdk]": "dpdk", | ||
"[bmv2]": "bmv2", | ||
"[P4Testgen]": "p4tools", | ||
"[P4Smith]": "p4tools", | ||
"[P4tools]": "p4tools", | ||
"[Tofino]":"tofino", | ||
"[p4tc]": "p4tc", | ||
"[p4fmt]": "p4fmt", | ||
"[core]":"core", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This list is missing some more labels: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fruffy can you please clear this doubts so that I can make changes accordingly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am currently traveling with limited access to internet. I will give this a thorough look later. For the other labels you should take a look at the issues that are being tagged with them and see whether you can find a mapping that works. |
||
"[p4-spec]": "p4-spec", | ||
"[control-plane]": "control-plane", | ||
"[P4runtime]":"control-plane", | ||
"[frontend]":"core", | ||
"[midend]":"core", | ||
"[parser]":"core", | ||
}; | ||
|
||
// Check if issue title contains bracketed keywords | ||
const title = issue.title.toLowerCase(); | ||
for (const [keyword, label] of Object.entries(labelMappings)) { | ||
if (title.includes(keyword.toLowerCase())) { | ||
labelsToAdd.push(label); | ||
} | ||
} | ||
|
||
if (labelsToAdd.length > 0) { | ||
github.rest.issues.addLabels({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
labels: labelsToAdd | ||
}); | ||
} |
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.
Could also be feat
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 mean in addition to [feature] we should also add [feat] and both will map to enhancement??
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.
For example, yes. You could have multiple variants.