This is an automated email from the ASF dual-hosted git repository. aglinxinyuan pushed a commit to branch chore/auto-assign-author in repository https://gitbox.apache.org/repos/asf/texera.git
commit 9871856effc655033ff7895934511aed1b11e8ee Author: Xinyuan Lin <[email protected]> AuthorDate: Tue Apr 28 22:50:28 2026 +0000 ci: auto-assign issue/PR author as assignee Adds .github/workflows/auto-assign.yml which assigns the author of a newly opened or reopened issue/PR as the default assignee. - issues: assigns the issue creator (skips if already assigned) - pull_request_target: assigns the PR author (skips bots and PRs that already have assignees) Pairs with the existing issue-triage workflow, which will then remove the 'triage' label automatically once the assignee is set. --- .github/workflows/auto-assign.yml | 126 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/.github/workflows/auto-assign.yml b/.github/workflows/auto-assign.yml new file mode 100644 index 0000000000..e01471dd71 --- /dev/null +++ b/.github/workflows/auto-assign.yml @@ -0,0 +1,126 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 +# +# http://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: Auto-assign author +on: + issues: + types: [opened, reopened] + pull_request_target: + types: [opened, reopened, ready_for_review] + +permissions: + issues: write + pull-requests: write + +jobs: + # -------------------------------------------------------- + # Assign the issue author as the assignee on new/reopened issues + # (skips if the issue already has assignees) + # -------------------------------------------------------- + assign-issue-author: + if: github.event_name == 'issues' + runs-on: ubuntu-latest + steps: + - name: Assign issue author + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + const issue = context.payload.issue; + const issue_number = issue.number; + const author = issue.user && issue.user.login; + + if (!author) { + core.info(`Issue #${issue_number} has no author login, skipping.`); + return; + } + + const existing = issue.assignees || []; + if (existing.length > 0) { + core.info( + `Issue #${issue_number} already has ${existing.length} assignee(s), skipping.` + ); + return; + } + + try { + await github.rest.issues.addAssignees({ + owner, + repo, + issue_number, + assignees: [author], + }); + core.info(`Assigned @${author} to issue #${issue_number}.`); + } catch (e) { + core.warning( + `Failed to assign @${author} to issue #${issue_number}: ${e.message}` + ); + throw e; + } + + # -------------------------------------------------------- + # Assign the PR author as the assignee on new/reopened PRs + # (skips if the PR already has assignees) + # -------------------------------------------------------- + assign-pr-author: + if: github.event_name == 'pull_request_target' + runs-on: ubuntu-latest + steps: + - name: Assign PR author + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + const pr = context.payload.pull_request; + const issue_number = pr.number; + const author = pr.user && pr.user.login; + + if (!author) { + core.info(`PR #${issue_number} has no author login, skipping.`); + return; + } + + // PR authors that are bots (e.g. dependabot[bot]) cannot be assigned. + if (pr.user.type === 'Bot' || author.endsWith('[bot]')) { + core.info(`PR #${issue_number} authored by bot @${author}, skipping.`); + return; + } + + const existing = pr.assignees || []; + if (existing.length > 0) { + core.info( + `PR #${issue_number} already has ${existing.length} assignee(s), skipping.` + ); + return; + } + + try { + // Note: PR assignees use the issues API (PRs are issues under the hood). + await github.rest.issues.addAssignees({ + owner, + repo, + issue_number, + assignees: [author], + }); + core.info(`Assigned @${author} to PR #${issue_number}.`); + } catch (e) { + core.warning( + `Failed to assign @${author} to PR #${issue_number}: ${e.message}` + ); + throw e; + }
