@@ -11,11 +11,13 @@ export async function run(): Promise<void> {
1111 const graphite_token : string = core . getInput ( 'graphite_token' )
1212 const endpoint : string = core . getInput ( 'endpoint' )
1313 const timeout : string = core . getInput ( 'timeout' )
14+ const pr_number_input : string = core . getInput ( 'pr_number' )
1415
1516 await requestWorkflow ( {
1617 graphite_token,
1718 endpoint,
18- timeout
19+ timeout,
20+ pr_number_input
1921 } )
2022 } catch ( error ) {
2123 // Fail the workflow run if an error occurs
@@ -26,16 +28,23 @@ export async function run(): Promise<void> {
2628async function requestWorkflow ( {
2729 graphite_token,
2830 endpoint,
29- timeout
31+ timeout,
32+ pr_number_input
3033} : {
3134 graphite_token : string
3235 endpoint : string
3336 timeout : string
37+ pr_number_input : string
3438} ) : Promise < void > {
3539 const {
3640 repo : { owner, repo }
3741 } = github . context
3842
43+ // Use pr_number input if provided, otherwise fall back to pull_request context
44+ const prNumber = pr_number_input
45+ ? parseInt ( pr_number_input , 10 )
46+ : github . context . payload . pull_request ?. number
47+
3948 const result = await fetch ( `${ endpoint } /api/v1/ci/optimizer` , {
4049 method : 'POST' ,
4150 body : JSON . stringify ( {
@@ -50,7 +59,7 @@ async function requestWorkflow({
5059 owner,
5160 name : repo
5261 } ,
53- pr : github . context . payload . pull_request ?. number ,
62+ pr : prNumber ,
5463 sha : github . context . sha ,
5564 ref : github . context . ref ,
5665 head_ref : process . env . GITHUB_HEAD_REF ,
@@ -97,7 +106,7 @@ async function requestWorkflow({
97106 owner,
98107 name : repo
99108 } ,
100- pr : github . context . payload . pull_request ?. number ,
109+ pr : prNumber ,
101110 sha : github . context . sha ,
102111 ref : github . context . ref ,
103112 head_ref : process . env . GITHUB_HEAD_REF ,
@@ -110,9 +119,7 @@ async function requestWorkflow({
110119 } )
111120 core . warning ( `Request body: ${ body } ` )
112121 core . warning ( `Response status: ${ result . status } ` )
113- core . warning (
114- `${ owner } /${ repo } /${ github . context . payload . pull_request ?. number } `
115- )
122+ core . warning ( `${ owner } /${ repo } /${ prNumber } ` )
116123 core . warning (
117124 'Response returned a non-200 status. Skipping Graphite checks.'
118125 )
0 commit comments