Skip to content

Commit fb567de

Browse files
author
Ashishkasaudhan
committed
Add separate full name fields for maintainers and team members
1 parent 9f25c4b commit fb567de

File tree

2 files changed

+95
-10
lines changed

2 files changed

+95
-10
lines changed

.github/ISSUE_TEMPLATE/team.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ body:
4848
required: false
4949
pattern: "^(@?[a-z0-9_.-]+(/[a-z0-9_.-]+)?)(,\\s*@?[a-z0-9_.-]+(/[a-z0-9_.-]+)?)*$"
5050

51+
- type: input
52+
id: maintainer_full_names
53+
attributes:
54+
label: "Maintainer Full Names (comma-separated)"
55+
description: "Enter full names for all maintainers (e.g., John Doe,Jane Smith)"
56+
placeholder: "John Doe,Jane Smith"
57+
validations:
58+
required: true
59+
pattern: "^([A-Za-z ,.'-]{3,100})(,\\s*[A-Za-z ,.'-]{3,100})*$"
60+
5161
- type: input
5262
id: team_members
5363
attributes:
@@ -59,10 +69,10 @@ body:
5969
pattern: "^(@?[a-z0-9_.-]+(/[a-z0-9_.-]+)?)(,\\s*@?[a-z0-9_.-]+(/[a-z0-9_.-]+)?)*$"
6070

6171
- type: input
62-
id: full_names
72+
id: member_full_names
6373
attributes:
64-
label: "GitHub User Full Names (comma-separated)"
65-
description: "Enter full names for all maintainers and members (e.g., John Doe,Jane Smith)"
74+
label: "Team Member Full Names (comma-separated)"
75+
description: "Enter full names for all team members (e.g., John Doe,Jane Smith)"
6676
placeholder: "John Doe,Jane Smith"
6777
validations:
6878
required: true

.github/workflows/issue_team_pr.yaml

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,18 @@ jobs:
130130
VISIBILITY=$(echo "$ISSUE_BODY" | awk '/^### Visibility$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
131131
PURPOSE=$(echo "$ISSUE_BODY" | awk '/^### Purpose$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
132132
MAINTAINERS=$(echo "$ISSUE_BODY" | awk '/^### Maintainers \(comma-separated\)$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
133+
MAINTAINER_FULL_NAMES=$(echo "$ISSUE_BODY" | awk '/^### Maintainer Full Names \(comma-separated\)$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
133134
TEAM_MEMBERS=$(echo "$ISSUE_BODY" | awk '/^### Team Members \(comma-separated\)$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
135+
MEMBER_FULL_NAMES=$(echo "$ISSUE_BODY" | awk '/^### Team Member Full Names \(comma-separated\)$/{getline; getline; print}' | sed 's/[`]//g' | xargs)
134136
135137
echo "Extracted Values:"
136138
echo "Team Name: '$TEAM_NAME'"
137139
echo "Visibility: '$VISIBILITY'"
138140
echo "Purpose: '$PURPOSE'"
139141
echo "Maintainers: '$MAINTAINERS'"
142+
echo "Maintainer Full Names: '$MAINTAINER_FULL_NAMES'"
140143
echo "Team Members: '$TEAM_MEMBERS'"
144+
echo "Member Full Names: '$MEMBER_FULL_NAMES'"
141145
echo "parent_team=$PARENT_TEAM" >> "$GITHUB_ENV"
142146
143147
if [[ ! "$TEAM_NAME" =~ ^TEAM-[a-zA-Z0-9_-]{1,20}$ ]]; then
@@ -149,27 +153,32 @@ jobs:
149153
PURPOSE=${PURPOSE:-Team created via automation}
150154
MAINTAINERS=${MAINTAINERS:-none}
151155
TEAM_MEMBERS=${TEAM_MEMBERS:-none}
156+
MAINTAINER_FULL_NAMES=${MAINTAINER_FULL_NAMES:-none}
157+
MEMBER_FULL_NAMES=${MEMBER_FULL_NAMES:-none}
152158
PARENT_TEAM=${PARENT_TEAM:-none}
153159
154160
echo "$TEAM_NAME" > team-name.txt
155161
echo "team_name=$TEAM_NAME" >> "$GITHUB_ENV"
156162
echo "visibility=$VISIBILITY" >> "$GITHUB_ENV"
157163
echo "purpose=$PURPOSE" >> "$GITHUB_ENV"
158164
echo "maintainers=$MAINTAINERS" >> "$GITHUB_ENV"
165+
echo "maintainer_full_names=$MAINTAINER_FULL_NAMES" >> "$GITHUB_ENV"
159166
echo "team_members=$TEAM_MEMBERS" >> "$GITHUB_ENV"
167+
echo "member_full_names=$MEMBER_FULL_NAMES" >> "$GITHUB_ENV"
160168
echo "parent_team=$PARENT_TEAM" >> "$GITHUB_ENV"
161169
162170
- name: Debug team info
163171
run: |
164172
echo "Maintainers to validate: $MAINTAINERS"
165173
echo "Team members to validate: $TEAM_MEMBERS"
174+
echo "Maintainer full names: $MAINTAINER_FULL_NAMES"
175+
echo "Member full names: $MEMBER_FULL_NAMES"
166176
env:
167177
MAINTAINERS: ${{ env.maintainers }}
168178
TEAM_MEMBERS: ${{ env.team_members }}
169-
- name: Install jq
170-
run: sudo apt-get install -y jq
171-
172-
- name: Validate GitHub usernames
179+
MAINTAINER_FULL_NAMES: ${{ env.maintainer_full_names }}
180+
MEMBER_FULL_NAMES: ${{ env.member_full_names }}
181+
- name: Validate GitHub usernames and full names
173182
if: env.maintainers != '_No response_' || env.team_members != '_No response_'
174183
shell: bash
175184
run: |
@@ -203,17 +212,67 @@ jobs:
203212
fi
204213
}
205214
215+
# Function to validate full name format
216+
validate_full_name_format() {
217+
local full_name=$1
218+
# Full name regex: 3-100 characters, letters, spaces, and some punctuation
219+
local full_name_regex='^[A-Za-z ,.'\''\\-]{3,100}$'
220+
if [[ ! "$full_name" =~ $full_name_regex ]]; then
221+
echo "::error::Invalid full name format: '$full_name'"
222+
echo "Full names must:"
223+
echo "- Be 3-100 characters long"
224+
echo "- Contain only letters, spaces, and basic punctuation (,.'-)"
225+
exit 1
226+
fi
227+
}
228+
229+
# Function to validate that the number of usernames matches the number of full names
230+
validate_count_match() {
231+
local user_type=$1
232+
local usernames=$2
233+
local full_names=$3
234+
235+
if [[ "$usernames" == "_No response_" || "$usernames" == "none" || -z "$usernames" ]]; then
236+
if [[ "$full_names" != "_No response_" && "$full_names" != "none" && -n "$full_names" ]]; then
237+
echo "::error::Full names provided for $user_type but no usernames were specified"
238+
exit 1
239+
fi
240+
return
241+
fi
242+
243+
- name: Install jq
244+
run: sudo apt-get install -y jq if [[ "$full_names" == "_No response_" || "$full_names" == "none" || -z "$full_names" ]]; then
245+
echo "::error::No full names provided for $user_type"
246+
exit 1
247+
fi
248+
249+
IFS=',' read -ra USERNAME_ARRAY <<< "$usernames"
250+
IFS=',' read -ra FULLNAME_ARRAY <<< "$full_names"
251+
252+
username_count=${#USERNAME_ARRAY[@]}
253+
fullname_count=${#FULLNAME_ARRAY[@]}
254+
255+
if [[ $username_count != $fullname_count ]]; then
256+
echo "::error::Mismatch between number of $user_type usernames ($username_count) and full names ($fullname_count)"
257+
exit 1
258+
fi
259+
}
260+
206261
# Main validation logic
207262
validate_users() {
208263
local user_type=$1
209264
local users=$2
265+
local full_names=$3
210266

211267
echo "Processing $user_type..."
212268
if [[ "$users" == "_No response_" || "$users" == "none" || -z "$users" ]]; then
213269
echo "No $user_type to validate"
214270
return
215271
fi
216272

273+
# Validate count match first
274+
validate_count_match "$user_type" "$users" "$full_names"
275+
217276
IFS=',' read -ra USER_ARRAY <<< "$users"
218277
for user in "${USER_ARRAY[@]}"; do
219278
trimmed=$(echo "$user" | xargs) # Trim whitespace
@@ -222,19 +281,33 @@ jobs:
222281
continue
223282
fi
224283

225-
echo "Validating $user_type: '$trimmed'"
284+
echo "Validating $user_type username: '$trimmed'"
226285
validate_username_format "$trimmed"
227286
validate_username_existence "$trimmed"
228287
done
288+
289+
IFS=',' read -ra FULLNAME_ARRAY <<< "$full_names"
290+
for full_name in "${FULLNAME_ARRAY[@]}"; do
291+
trimmed=$(echo "$full_name" | xargs) # Trim whitespace
292+
if [ -z "$trimmed" ]; then
293+
echo "::warning::Empty full name found in $user_type list"
294+
continue
295+
fi
296+
297+
echo "Validating $user_type full name: '$trimmed'"
298+
validate_full_name_format "$trimmed"
299+
done
229300
}
230301

231302
# Validate both maintainers and team members
232-
validate_users "maintainers" "$MAINTAINERS"
233-
validate_users "team members" "$TEAM_MEMBERS"
303+
validate_users "maintainers" "$MAINTAINERS" "$MAINTAINER_FULL_NAMES"
304+
validate_users "team members" "$TEAM_MEMBERS" "$MEMBER_FULL_NAMES"
234305
env:
235306
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
236307
MAINTAINERS: ${{ env.maintainers }}
237308
TEAM_MEMBERS: ${{ env.team_members }}
309+
MAINTAINER_FULL_NAMES: ${{ env.maintainer_full_names }}
310+
MEMBER_FULL_NAMES: ${{ env.member_full_names }}
238311

239312
- name: Create Pull Request for Team
240313
if: steps.classify.outputs.type == 'team'
@@ -250,7 +323,9 @@ jobs:
250323
**Visibility:** ${{ env.visibility }}
251324
**Purpose:** ${{ env.purpose }}
252325
**Maintainers:** ${{ env.maintainers }}
326+
**Maintainer Full Names:** ${{ env.maintainer_full_names }}
253327
**Team Members:** ${{ env.team_members }}
328+
**Team Member Full Names:** ${{ env.member_full_names }}
254329
255330
Generated from issue #${{ github.event.issue.number }}
256331
branch: "team-request/${{ github.event.issue.number }}"

0 commit comments

Comments
 (0)