This is an automated email from the ASF dual-hosted git repository. yiconghuang pushed a commit to branch chore/action/assign-issue-triage-label in repository https://gitbox.apache.org/repos/asf/texera.git
commit cc49bb09aab179283b79ee1fea3f75592490e65a Author: Yicong Huang <[email protected]> AuthorDate: Sun Nov 16 23:02:44 2025 -0800 Add issue triage workflow for label management Signed-off-by: Yicong Huang <[email protected]> --- .github/workflows/issue-triage.yml | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml new file mode 100644 index 0000000000..23ca78a8e2 --- /dev/null +++ b/.github/workflows/issue-triage.yml @@ -0,0 +1,91 @@ +# 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: Issue triage +on: + issues: + types: [assigned, unassigned] + pull_request: + types: [closed] + +permissions: + issues: write + pull-requests: read + +jobs: + # -------------------------------------------------------- + # 1) Issue triage: add/remove "triage" on assignment changes + # -------------------------------------------------------- + issue-triage: + if: github.event_name == 'issues' + runs-on: ubuntu-latest + steps: + - name: Remove 'triage' label when issue is assigned + if: github.event.action == 'assigned' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + const issue_number = context.payload.issue.number; + + try { + await github.rest.issues.removeLabel({ + owner, + repo, + issue_number, + name: 'triage', + }); + core.info(`Removed 'triage' from issue #${issue_number}`); + } catch (e) { + if (e.status === 404) { + core.info(`Issue #${issue_number} has no 'triage' label, nothing to remove.`); + } else { + core.warning(`Failed to remove 'triage' from issue #${issue_number}: ${e.message}`); + throw e; + } + } + + - name: Add 'triage' label when issue is unassigned and has no assignees + if: github.event.action == 'unassigned' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const issue = context.payload.issue; + const { owner, repo } = context.repo; + const issue_number = issue.number; + + const assignees = issue.assignees || []; + if (assignees.length > 0) { + core.info( + `Issue #${issue_number} still has ${assignees.length} assignee(s), not adding 'triage'.` + ); + return; + } + + core.info(`Issue #${issue_number} has no assignees, adding 'triage' label.`); + try { + await github.rest.issues.addLabels({ + owner, + repo, + issue_number, + labels: ['triage'], + }); + } catch (e) { + core.warning(`Failed to add 'triage' to issue #${issue_number}: ${e.message}`); + throw e; + }
