@@ -10,57 +10,15 @@ interface PR {
1010}
1111
1212async function main ( ) {
13- const token = process . env . GITHUB_TOKEN
14- if ( ! token ) throw new Error ( "GITHUB_TOKEN not set" )
15-
16- const repo = process . env . GITHUB_REPOSITORY
17- if ( ! repo ) throw new Error ( "GITHUB_REPOSITORY not set" )
18-
19- const [ owner , repoName ] = repo . split ( "/" )
20-
2113 console . log ( "Fetching open contributor PRs..." )
2214
23- const prsQuery = `
24- query($owner: String!, $repo: String!, $labels: [String!]) {
25- repository(owner: $owner, name: $repo) {
26- pullRequests(
27- states: OPEN,
28- labels: $labels,
29- first: 100,
30- orderBy: {field: CREATED_AT, direction: ASC}
31- ) {
32- nodes {
33- number
34- headRefName
35- headRefOid
36- createdAt
37- isDraft
38- title
39- }
40- }
41- }
42- }
43- `
44-
45- const queryResult = await fetch ( "https://api.github.com/graphql" , {
46- method : "POST" ,
47- headers : {
48- Authorization : `Bearer ${ token } ` ,
49- "Content-Type" : "application/json" ,
50- } ,
51- body : JSON . stringify ( {
52- query : prsQuery ,
53- variables : { owner, repo : repoName , labels : [ "contributor" ] } ,
54- } ) ,
55- } ) . then ( ( x ) => x . json ( ) )
56-
57- if ( queryResult . errors ) {
58- console . error ( "GraphQL errors:" , queryResult . errors )
59- throw new Error ( "Failed to fetch PRs" )
15+ const prsResult =
16+ await $ `gh pr list --label contributor --state open --json number,headRefName,headRefOid,createdAt,isDraft,title --limit 100` . nothrow ( )
17+ if ( prsResult . exitCode !== 0 ) {
18+ throw new Error ( `Failed to fetch PRs: ${ prsResult . stderr } ` )
6019 }
6120
62- const allPRs : PR [ ] = queryResult . data . repository . pullRequests . nodes
63-
21+ const allPRs : PR [ ] = JSON . parse ( prsResult . stdout )
6422 const prs = allPRs . filter ( ( pr ) => ! pr . isDraft )
6523
6624 console . log ( `Found ${ prs . length } open non-draft contributor PRs` )
0 commit comments