From ee07f7d26be058ae35445949a624612e776d8cfa Mon Sep 17 00:00:00 2001 From: mitul001 Date: Thu, 16 Apr 2026 09:57:16 +0530 Subject: [PATCH] refactor: parameterize mentor-duty label Signed-off-by: mitul001 --- .github/scripts/bot-assignment-check.sh | 17 ++++++++++++----- .github/workflows/bot-assignment-check.yml | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/scripts/bot-assignment-check.sh b/.github/scripts/bot-assignment-check.sh index fe9c40d52..06fc30392 100644 --- a/.github/scripts/bot-assignment-check.sh +++ b/.github/scripts/bot-assignment-check.sh @@ -1,6 +1,13 @@ #!/bin/bash set -Eeuo pipefail +# Configuration for labels (overridable from workflow env) +MENTOR_LABEL="${MENTOR_LABEL:-notes: mentor-duty}" +if [ -z "${MENTOR_LABEL}" ]; then + echo "Error: Missing required environment variable (MENTOR_LABEL)." >&2 + exit 1 +fi + # Validate required env vars if [ -z "${ASSIGNEE:-}" ] || [ -z "${ISSUE_NUMBER:-}" ] || [ -z "${REPO:-}" ]; then echo "Error: Missing required environment variables (ASSIGNEE, ISSUE_NUMBER, REPO)." @@ -36,20 +43,20 @@ issue_has_gfi() { } # Count open assignments for a user -# For triage users (mentors), excludes issues with 'mentor-duty' label +# For triage users (mentors), excludes issues with '${MENTOR_LABEL}' label # This allows mentors to be assigned to mentorship issues without consuming their assignment limit assignments_count() { local permission="${1:-none}" if [[ "$permission" == "triage" ]]; then - echo "Triage user detected — excluding mentor-duty issues from count." >&2 - # For triage users, exclude issues with 'mentor-duty' label + echo "Triage user detected — excluding ${MENTOR_LABEL} issues from count." >&2 + # For triage users, exclude issues with the configured mentor label gh api "repos/${REPO}/issues?per_page=100&page=1" \ -f assignee="${ASSIGNEE}" \ -f state=open \ - --jq '.[] + --jq --arg mentor_label "$MENTOR_LABEL" '.[] | select(.pull_request == null) - | select(any(.labels[]; .name == "mentor-duty") | not) + | select(any(.labels[]; .name == $mentor_label) | not) | .number' | grep -c . || echo 0 else # For non-triage users, count all open assignments diff --git a/.github/workflows/bot-assignment-check.yml b/.github/workflows/bot-assignment-check.yml index 4fb3cb791..032dd1815 100644 --- a/.github/workflows/bot-assignment-check.yml +++ b/.github/workflows/bot-assignment-check.yml @@ -25,6 +25,7 @@ jobs: ASSIGNEE: ${{ github.event.assignee.login }} ISSUE_NUMBER: ${{ github.event.issue.number }} REPO: ${{ github.repository }} + MENTOR_LABEL: "notes: mentor-duty" run: | # Make script executable (just in case permissions were lost during checkout) chmod +x .github/scripts/bot-assignment-check.sh