@@ -19,28 +19,37 @@ interface PRMeta {
1919 assignees : components [ 'schemas' ] [ 'simple-user' ] [ ] ;
2020}
2121
22- const PR_URL = await $ `gh api graphql -f query='{
22+ const PR_DATA = await $ `gh api graphql -f query='{
2323 repository(owner: "${ repositoryOwner } ", name: "${ repositoryName } ") {
2424 issue(number: ${ issueNumber } ) {
2525 closedByPullRequestsReferences(first: 10) {
2626 nodes {
2727 url
2828 merged
29+ mergeCommit {
30+ oid
31+ }
2932 }
3033 }
3134 }
3235 }
33- }' --jq '.data.repository.issue.closedByPullRequestsReferences.nodes[] | select(.merged == true) | .url' | head -n 1` ;
36+ }' --jq '.data.repository.issue.closedByPullRequestsReferences.nodes[] | select(.merged == true) | {url: .url, mergeCommitSha: .mergeCommit.oid} ' | head -n 1` ;
3437
35- if ( ! PR_URL . text ( ) . trim ( ) )
36- throw new ReferenceError ( 'No merged PR is found for the given issue number.' ) ;
38+ const prData = PR_DATA . text ( ) . trim ( ) ;
39+
40+ if ( ! prData ) throw new ReferenceError ( 'No merged PR is found for the given issue number.' ) ;
41+
42+ const { url : PR_URL , mergeCommitSha } = JSON . parse ( prData ) ;
43+
44+ if ( ! PR_URL || ! mergeCommitSha ) throw new Error ( 'Missing required fields in PR data' ) ;
45+
46+ console . table ( { PR_URL , mergeCommitSha } ) ;
3747
3848const { author, assignees } : PRMeta = await (
3949 await $ `gh pr view ${ PR_URL } --json author,assignees`
4050) . json ( ) ;
4151
42- // Function to check if a user is a Copilot/bot user
43- function isCopilotUser ( login : string ) : boolean {
52+ function isBotUser ( login : string ) {
4453 const lowerLogin = login . toLowerCase ( ) ;
4554 return (
4655 lowerLogin . includes ( 'copilot' ) ||
@@ -50,19 +59,17 @@ function isCopilotUser(login: string): boolean {
5059 ) ;
5160}
5261
53- // Filter out Copilot and bot users from the list
62+ // Filter out Bot users from the list
5463const allUsers = [ author . login , ...assignees . map ( ( { login } ) => login ) ] ;
55- const users = allUsers . filter ( login => ! isCopilotUser ( login ) ) ;
64+ const users = allUsers . filter ( login => ! isBotUser ( login ) ) ;
5665
5766console . log ( `All users: ${ allUsers . join ( ', ' ) } ` ) ;
58- console . log ( `Filtered users (excluding bots/copilot ): ${ users . join ( ', ' ) } ` ) ;
67+ console . log ( `Filtered users (excluding bots): ${ users . join ( ', ' ) } ` ) ;
5968
60- // Handle case where all users are bots/copilot
61- if ( users . length === 0 ) {
62- console . log ( 'No real users found (all users are bots/copilot). Skipping reward distribution.' ) ;
63- console . log ( `Filtered users: ${ allUsers . join ( ', ' ) } ` ) ;
64- process . exit ( 0 ) ;
65- }
69+ if ( ! users [ 0 ] )
70+ throw new ReferenceError (
71+ 'No real users found (all users are bots). Skipping reward distribution.' ,
72+ ) ;
6673
6774const rewardNumber = parseFloat ( reward ) ;
6875
@@ -86,7 +93,7 @@ console.log(listText);
8693
8794await $ `git config --global user.name "github-actions[bot]"` ;
8895await $ `git config --global user.email "github-actions[bot]@users.noreply.github.com"` ;
89- await $ `git tag -a "reward-${ issueNumber } " -m ${ listText } ` ;
96+ await $ `git tag -a "reward-${ issueNumber } " ${ mergeCommitSha } -m ${ listText } ` ;
9097await $ `git push origin --tags` ;
9198
9299const commentBody = `## Reward data
0 commit comments