|
1 | 1 | #!/bin/bash |
2 | 2 | set -Eeuo pipefail |
3 | 3 |
|
| 4 | +# Configuration for labels (overridable from workflow env) |
| 5 | +MENTOR_LABEL="${MENTOR_LABEL:-notes: mentor-duty}" |
| 6 | +if [ -z "${MENTOR_LABEL}" ]; then |
| 7 | + echo "Error: Missing required environment variable (MENTOR_LABEL)." >&2 |
| 8 | + exit 1 |
| 9 | +fi |
| 10 | + |
4 | 11 | # Validate required env vars |
5 | 12 | if [ -z "${ASSIGNEE:-}" ] || [ -z "${ISSUE_NUMBER:-}" ] || [ -z "${REPO:-}" ]; then |
6 | 13 | echo "Error: Missing required environment variables (ASSIGNEE, ISSUE_NUMBER, REPO)." |
@@ -36,20 +43,20 @@ issue_has_gfi() { |
36 | 43 | } |
37 | 44 |
|
38 | 45 | # Count open assignments for a user |
39 | | -# For triage users (mentors), excludes issues with 'mentor-duty' label |
| 46 | +# For triage users (mentors), excludes issues with '${MENTOR_LABEL}' label |
40 | 47 | # This allows mentors to be assigned to mentorship issues without consuming their assignment limit |
41 | 48 | assignments_count() { |
42 | 49 | local permission="${1:-none}" |
43 | 50 |
|
44 | 51 | if [[ "$permission" == "triage" ]]; then |
45 | | - echo "Triage user detected — excluding mentor-duty issues from count." >&2 |
46 | | - # For triage users, exclude issues with 'mentor-duty' label |
| 52 | + echo "Triage user detected — excluding ${MENTOR_LABEL} issues from count." >&2 |
| 53 | + # For triage users, exclude issues with the configured mentor label |
47 | 54 | gh api "repos/${REPO}/issues?per_page=100&page=1" \ |
48 | 55 | -f assignee="${ASSIGNEE}" \ |
49 | 56 | -f state=open \ |
50 | | - --jq '.[] |
| 57 | + --jq --arg mentor_label "$MENTOR_LABEL" '.[] |
51 | 58 | | select(.pull_request == null) |
52 | | - | select(any(.labels[]; .name == "mentor-duty") | not) |
| 59 | + | select(any(.labels[]; .name == $mentor_label) | not) |
53 | 60 | | .number' | grep -c . || echo 0 |
54 | 61 | else |
55 | 62 | # For non-triage users, count all open assignments |
|
0 commit comments