-
Notifications
You must be signed in to change notification settings - Fork 1k
Add Auto-Assignment GitHub Action for Issues #980
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
760d437
852a6d3
1985b0d
c8aa1ac
2c042ff
ee9fd91
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,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 }); |
| 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']; | ||
|
Contributor
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. The round-robin assignment logic is implemented, but the |
||
|
|
||
| // 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
Contributor
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. The error handling in the 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'); | ||
| } | ||
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.
The
issueAssigneesListis 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.