Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/auto-assignment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: A2UI Issue Auto-Assignment

on:
issues:
types: [opened]

permissions:
contents: read
issues: write

jobs:
auto-assign:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run auto-assignment script
uses: actions/github-script@v7
with:
script: |
const path = require('path');
const { pathToFileURL } = require('url');

const filePath = path.resolve('./scripts/auto-assignment.mjs');
const fileUrl = pathToFileURL(filePath).href;

const importedModule = await import(fileUrl);
await importedModule.default({ github, context });
62 changes: 62 additions & 0 deletions scripts/auto-assignment.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export default async function autoAssign({ github, context }) {
console.log('A2UI Issue Auto-assignment script started');

let issueNumber;
let activeAssigneesList;

// Hardcoded assignee lists
const issueAssigneesList = ['selamw1'];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The issueAssigneesList is hardcoded with a single assignee. This approach limits the flexibility and scalability of the auto-assignment script. For better maintainability, consider externalizing this list, perhaps by using GitHub Action inputs or repository secrets, so that changes to the team members do not require modifying and redeploying the script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The round-robin assignment logic is implemented, but the issueAssigneesList currently contains only one assignee. This means the round-robin functionality won't be utilized until more assignees are added. If the intention is to distribute work, ensure this list is populated with multiple team members. Otherwise, the round-robin logic is currently redundant.


// Determine event type
if (context.payload.issue) {
issueNumber = context.payload.issue.number;
activeAssigneesList = issueAssigneesList;
console.log('Event Type: Issue');
} else {
console.log('Not an Issue event. Exiting.');
return;
}

console.log('Target assignees list:', activeAssigneesList);

if (!activeAssigneesList || activeAssigneesList.length === 0) {
console.log('No assignees configured for this type.');
return;
}

// Round-robin assignment
const selection = issueNumber % activeAssigneesList.length;
const assigneeToAssign = activeAssigneesList[selection];

console.log(`Assigning #${issueNumber} to: ${assigneeToAssign}`);

try {
await github.rest.issues.addAssignees({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
assignees: [assigneeToAssign],
});
console.log('Assignment successful');
} catch (error) {
console.log('Failed to assign:', error.message);
Comment on lines +57 to +58
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error handling in the catch block only logs the error message. For a GitHub Action, it's often more robust to explicitly fail the action when an assignment fails. This ensures that the workflow run reflects the failure and can trigger appropriate alerts or subsequent actions. Consider re-throwing the error or using core.setFailed (if actions/core is available) to indicate a critical failure.

    console.log('Failed to assign:', error.message);
    throw new Error(`Failed to assign issue #${issueNumber}: ${error.message}`);

}

console.log('A2UI Issue Auto-assignment script completed');
}
Loading