diff --git a/.github/workflows/auto-assignment.yml b/.github/workflows/auto-assignment.yml new file mode 100644 index 000000000..aed5122ec --- /dev/null +++ b/.github/workflows/auto-assignment.yml @@ -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 }); \ No newline at end of file diff --git a/scripts/auto-assignment.mjs b/scripts/auto-assignment.mjs new file mode 100644 index 000000000..8fd31029b --- /dev/null +++ b/scripts/auto-assignment.mjs @@ -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']; + + // 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); + } + + console.log('A2UI Issue Auto-assignment script completed'); +} \ No newline at end of file