Skip to content

Commit 64aaa24

Browse files
committed
Add script file
1 parent f1f9821 commit 64aaa24

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const fs = require('fs');
2+
const { parse } = require('yaml');
3+
4+
module.exports = async ({ github, context, core }) => {
5+
// Extract component name from label
6+
const labelName = context.payload.label.name;
7+
8+
if (!labelName.startsWith('component:')) {
9+
core.setFailed('Label does not match expected pattern');
10+
return;
11+
}
12+
13+
const componentName = labelName.replace('component:', '');
14+
console.log(`Processing component: ${componentName}`);
15+
16+
// Read and parse component_owners.yml
17+
const yamlContent = fs.readFileSync('.github/component_owners.yml', 'utf8');
18+
const data = parse(yamlContent);
19+
20+
if (!data || !data.components) {
21+
core.setFailed('Invalid component_owners.yml structure');
22+
return;
23+
}
24+
25+
const components = data.components;
26+
27+
if (!(componentName in components)) {
28+
core.setFailed(`Component '${componentName}' not found in component_owners.yml`);
29+
return;
30+
}
31+
32+
const owners = components[componentName];
33+
34+
if (!owners || owners.length === 0) {
35+
core.setFailed(`No owners found for component '${componentName}'`);
36+
return;
37+
}
38+
39+
console.log(`Found owners: ${owners.join(', ')}`);
40+
41+
// Assign the issue to the owners
42+
const issueNumber = context.payload.issue.number;
43+
44+
await github.rest.issues.addAssignees({
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
issue_number: issueNumber,
48+
assignees: owners
49+
});
50+
51+
console.log(`Successfully assigned issue #${issueNumber} to ${owners.join(', ')}`);
52+
};

0 commit comments

Comments
 (0)