Skip to content

Commit d50db0a

Browse files
authored
Add Auto-Assignment GitHub Action for Issues (#980)
* Add auto-assignment GitHub Actions script * add Google open source license * The assignee list has been updated
1 parent e488794 commit d50db0a

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: A2UI Issue Auto-Assignment
16+
17+
on:
18+
issues:
19+
types: [opened]
20+
21+
permissions:
22+
contents: read
23+
issues: write
24+
25+
jobs:
26+
auto-assign:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Run auto-assignment script
34+
uses: actions/github-script@v7
35+
with:
36+
script: |
37+
const path = require('path');
38+
const { pathToFileURL } = require('url');
39+
40+
const filePath = path.resolve('./scripts/auto-assignment.mjs');
41+
const fileUrl = pathToFileURL(filePath).href;
42+
43+
const importedModule = await import(fileUrl);
44+
await importedModule.default({ github, context });

scripts/auto-assignment.mjs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
export default async function autoAssign({ github, context }) {
18+
console.log('A2UI Issue Auto-assignment script started');
19+
20+
let issueNumber;
21+
let activeAssigneesList;
22+
23+
// Hardcoded assignee lists
24+
const issueAssigneesList = ['selamw1'];
25+
26+
// Determine event type
27+
if (context.payload.issue) {
28+
issueNumber = context.payload.issue.number;
29+
activeAssigneesList = issueAssigneesList;
30+
console.log('Event Type: Issue');
31+
} else {
32+
console.log('Not an Issue event. Exiting.');
33+
return;
34+
}
35+
36+
console.log('Target assignees list:', activeAssigneesList);
37+
38+
if (!activeAssigneesList || activeAssigneesList.length === 0) {
39+
console.log('No assignees configured for this type.');
40+
return;
41+
}
42+
43+
// Round-robin assignment
44+
const selection = issueNumber % activeAssigneesList.length;
45+
const assigneeToAssign = activeAssigneesList[selection];
46+
47+
console.log(`Assigning #${issueNumber} to: ${assigneeToAssign}`);
48+
49+
try {
50+
await github.rest.issues.addAssignees({
51+
issue_number: issueNumber,
52+
owner: context.repo.owner,
53+
repo: context.repo.repo,
54+
assignees: [assigneeToAssign],
55+
});
56+
console.log('Assignment successful');
57+
} catch (error) {
58+
console.log('Failed to assign:', error.message);
59+
}
60+
61+
console.log('A2UI Issue Auto-assignment script completed');
62+
}

0 commit comments

Comments
 (0)