@@ -109,6 +109,10 @@ export async function addAdmin(
109109) : Promise < void > {
110110 core . info ( `Adding Admin to Class Request: #${ payload . issue . number } ` )
111111
112+ // Create the authenticated Octokit client.
113+ const token : string = core . getInput ( 'github_token' , { required : true } )
114+ const octokit = github . getOctokit ( token )
115+
112116 // Get the user from the comment body.
113117 // Format: .add-admin handle,email
114118 if (
@@ -123,6 +127,27 @@ export async function addAdmin(
123127 email : payload . comment . body . split ( ' ' ) [ 1 ] . split ( ',' ) [ 1 ]
124128 }
125129
130+ // Check if the user is a GitHub/Microsoft employee.
131+ const response : { user : { isEmployee : boolean ; email : string } } =
132+ await octokit . graphql (
133+ `
134+ query($login: String!) {
135+ user(login: $login) {
136+ isEmployee
137+ email
138+ }
139+ }
140+ ` ,
141+ { login : user . handle }
142+ )
143+
144+ // Do not add the admin if they are not a GitHub or Microsoft employee.
145+ if (
146+ ! response . user . isEmployee &&
147+ ! response . user . email . includes ( '@microsoft.com' )
148+ )
149+ throw new Error ( 'Admins Must be GitHub/Microsoft Employees' )
150+
126151 await teams . addUser ( request , user , 'maintainer' )
127152
128153 // Comment on the issue with the summary.
@@ -206,13 +231,13 @@ export async function removeAdmin(
206231 const response : { user : { isEmployee : boolean ; email : string } } =
207232 await octokit . graphql (
208233 `
209- query($login: String!) {
210- user(login: $login) {
211- isEmployee
212- email
234+ query($login: String!) {
235+ user(login: $login) {
236+ isEmployee
237+ email
238+ }
213239 }
214- }
215- ` ,
240+ ` ,
216241 { login : user . handle }
217242 )
218243
0 commit comments