@@ -39,9 +39,41 @@ const { author, assignees }: PRMeta = await (
3939 await $ `gh pr view ${ PR_URL } --json author,assignees`
4040) . json ( ) ;
4141
42- const users = [ author . login , ...assignees . map ( ( { login } ) => login ) ] ;
42+ // Function to check if a user is a Copilot/bot user
43+ function isCopilotUser ( login : string ) : boolean {
44+ const lowerLogin = login . toLowerCase ( ) ;
45+ return (
46+ lowerLogin . includes ( 'copilot' ) ||
47+ lowerLogin . includes ( '[bot]' ) ||
48+ lowerLogin === 'github-actions[bot]' ||
49+ lowerLogin . endsWith ( '[bot]' )
50+ ) ;
51+ }
52+
53+ // Filter out Copilot and bot users from the list
54+ const allUsers = [ author . login , ...assignees . map ( ( { login } ) => login ) ] ;
55+ const users = allUsers . filter ( ( login ) => ! isCopilotUser ( login ) ) ;
56+
57+ console . log ( `All users: ${ allUsers . join ( ', ' ) } ` ) ;
58+ console . log ( `Filtered users (excluding bots/copilot): ${ users . join ( ', ' ) } ` ) ;
59+
60+ // Handle case where all users are bots/copilot
61+ if ( users . length === 0 ) {
62+ console . log (
63+ 'No real users found (all users are bots/copilot). Skipping reward distribution.' ,
64+ ) ;
65+ console . log ( `Filtered users: ${ allUsers . join ( ', ' ) } ` ) ;
66+ process . exit ( 0 ) ;
67+ }
68+
69+ const rewardNumber = parseFloat ( reward ) ;
70+
71+ if ( isNaN ( rewardNumber ) || rewardNumber <= 0 )
72+ throw new RangeError (
73+ `Reward amount is not a valid number, can not proceed with reward distribution. Received reward value: ${ reward } ` ,
74+ ) ;
4375
44- const averageReward = ( parseFloat ( reward ) / users . length ) . toFixed ( 2 ) ;
76+ const averageReward = ( rewardNumber / users . length ) . toFixed ( 2 ) ;
4577
4678const list : Reward [ ] = users . map ( ( login ) => ( {
4779 issue : `#${ issueNumber } ` ,
0 commit comments