@@ -4,15 +4,15 @@ import {RequestError} from '@octokit/request-error';
44import CONST from '@github/libs/CONST' ;
55import GithubUtils from '@github/libs/GithubUtils' ;
66
7- const AUTHORIZED_ASSOCIATIONS = new Set ( [ 'MEMBER' , 'OWNER' , 'CONTRIBUTOR' ] ) ;
7+ const AUTHORIZED_ASSOCIATIONS = new Set ( [ 'MEMBER' , 'OWNER' , 'CONTRIBUTOR' , 'COLLABORATOR' ] ) ;
88const CONTRIBUTOR_PLUS_TEAM_SLUG = 'contributor-plus' ;
99
1010const ISSUE_URL_PATTERN = / h t t p s : \/ \/ g i t h u b \. c o m \/ ( E x p e n s i f y \/ [ ^ / ] + ) \/ i s s u e s \/ ( \d + ) / g;
1111
1212type IsAuthorizedContributorParams = {
1313 prNumber : number ;
14- prAuthor : string ;
15- authorAssociation : string ;
14+ actor : string ;
15+ actorAssociation : string ;
1616 repoOwner : string ;
1717 repoName : string ;
1818 githubToken : string ;
@@ -70,7 +70,7 @@ async function isContributorPlusMember(username: string, orgToken: string): Prom
7070 }
7171}
7272
73- async function isAuthorizedViaLinkedIssues ( prBody : string , prAuthor : string ) : Promise < boolean > {
73+ async function isAuthorizedViaLinkedIssues ( prBody : string , actor : string ) : Promise < boolean > {
7474 for ( const match of prBody . matchAll ( ISSUE_URL_PATTERN ) ) {
7575 const link = parseExpensifyLink ( match ) ;
7676 if ( ! link ) {
@@ -87,12 +87,12 @@ async function isAuthorizedViaLinkedIssues(prBody: string, prAuthor: string): Pr
8787 issue_number : number ,
8888 } ) ;
8989
90- if ( issue . assignees ?. some ( ( assignee ) => assignee . login ?. toLowerCase ( ) === prAuthor . toLowerCase ( ) ) ) {
91- console . log ( `${ prAuthor } is assigned to ${ repoFullName } #${ number } . Authorized.` ) ;
90+ if ( issue . assignees ?. some ( ( assignee ) => assignee . login ?. toLowerCase ( ) === actor . toLowerCase ( ) ) ) {
91+ console . log ( `${ actor } is assigned to ${ repoFullName } #${ number } . Authorized.` ) ;
9292 return true ;
9393 }
9494
95- console . log ( `${ prAuthor } is NOT assigned to ${ repoFullName } #${ number } .` ) ;
95+ console . log ( `${ actor } is NOT assigned to ${ repoFullName } #${ number } .` ) ;
9696 } catch ( error : unknown ) {
9797 logVerificationError ( repoFullName , number , error ) ;
9898 }
@@ -104,17 +104,17 @@ async function isAuthorizedViaLinkedIssues(prBody: string, prAuthor: string): Pr
104104/**
105105 * Returns whether a PR author is authorized to contribute per Expensify external contributor rules.
106106 */
107- async function isAuthorizedContributor ( { prNumber, prAuthor , authorAssociation , repoOwner, repoName, githubToken, orgToken} : IsAuthorizedContributorParams ) : Promise < boolean > {
108- if ( AUTHORIZED_ASSOCIATIONS . has ( authorAssociation ) ) {
109- console . log ( `${ prAuthor } is ${ authorAssociation } . Authorized.` ) ;
107+ async function isAuthorizedContributor ( { prNumber, actor , actorAssociation , repoOwner, repoName, githubToken, orgToken} : IsAuthorizedContributorParams ) : Promise < boolean > {
108+ if ( AUTHORIZED_ASSOCIATIONS . has ( actorAssociation ) ) {
109+ console . log ( `${ actor } is ${ actorAssociation } . Authorized.` ) ;
110110 return true ;
111111 }
112112
113- if ( await isContributorPlusMember ( prAuthor , orgToken ) ) {
113+ if ( await isContributorPlusMember ( actor , orgToken ) ) {
114114 return true ;
115115 }
116116
117- console . log ( `${ prAuthor } has association "${ authorAssociation } ". Checking linked issues...` ) ;
117+ console . log ( `${ actor } has association "${ actorAssociation } ". Checking linked issues...` ) ;
118118
119119 GithubUtils . initOctokitWithToken ( githubToken ) ;
120120
@@ -126,28 +126,28 @@ async function isAuthorizedContributor({prNumber, prAuthor, authorAssociation, r
126126 } ) ;
127127
128128 const prBody = pr . body ?? '' ;
129- const isAuthorized = await isAuthorizedViaLinkedIssues ( prBody , prAuthor ) ;
129+ const isAuthorized = await isAuthorizedViaLinkedIssues ( prBody , actor ) ;
130130
131131 if ( ! isAuthorized ) {
132- console . log ( `No valid authorization found for ${ prAuthor } .` ) ;
132+ console . log ( `No valid authorization found for ${ actor } .` ) ;
133133 }
134134
135135 return isAuthorized ;
136136}
137137
138138async function run ( ) : Promise < void > {
139139 const prNumber = Number . parseInt ( core . getInput ( 'PR_NUMBER' , { required : true } ) , 10 ) ;
140- const prAuthor = core . getInput ( 'PR_AUTHOR ' , { required : true } ) ;
141- const authorAssociation = core . getInput ( 'AUTHOR_ASSOCIATION ' , { required : true } ) ;
140+ const actor = core . getInput ( 'ACTOR ' , { required : true } ) ;
141+ const actorAssociation = core . getInput ( 'ACTOR_ASSOCIATION ' , { required : true } ) ;
142142 const githubToken = core . getInput ( 'GITHUB_TOKEN' , { required : true } ) ;
143143 const orgToken = core . getInput ( 'OS_BOTIFY_TOKEN' , { required : true } ) ;
144144
145145 const { owner, repo} = github . context . repo ;
146146
147147 const isAuthorized = await isAuthorizedContributor ( {
148148 prNumber,
149- prAuthor ,
150- authorAssociation ,
149+ actor ,
150+ actorAssociation ,
151151 repoOwner : owner ,
152152 repoName : repo ,
153153 githubToken,
0 commit comments