-
Notifications
You must be signed in to change notification settings - Fork 20
48 lines (42 loc) · 1.92 KB
/
Copy pathissue-auto-label.yml
File metadata and controls
48 lines (42 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
name: Auto-label issues by component
on:
issues:
types: [opened]
jobs:
auto-label:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const body = context.payload.issue.body || '';
// Issue forms render dropdown values as:
// ### Component\n\n<value>\n
const match = body.match(/### Component\s*\r?\n\r?\n(.+)/);
if (!match) {
console.log('No Component field found in issue body — skipping.');
return;
}
const component = match[1].trim();
// Canonical labels matching directories in this repo:
// A365 -> src/microsoft/opentelemetry/a365/
// Langchain -> src/microsoft/opentelemetry/_genai/_langchain/
// Agent Framework -> src/microsoft/opentelemetry/_agent_framework/
// Semantic Kernel -> src/microsoft/opentelemetry/_semantic_kernel/
// Azure Monitor -> src/microsoft/opentelemetry/_azure_monitor/
// Distro -> src/microsoft/opentelemetry/ (top-level distro modules)
const knownLabels = ['A365', 'Langchain', 'Azure Monitor', 'Distro', 'Agent Framework', 'Semantic Kernel'];
const label = knownLabels.find(l => l.toLowerCase() === component.toLowerCase());
if (!label) {
console.log(`Component "${component}" does not map to a label — skipping.`);
return;
}
console.log(`Adding label "${label}" to issue #${context.issue.number}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label],
});