@@ -26,6 +26,14 @@ const { createRateLimitAwareGithub } = require("./github_rate_limit_logger.cjs")
2626 */
2727function setupGlobals ( coreModule , githubModule , contextModule , execModule , ioModule , getOctokitFn ) {
2828 global . core = coreModule ;
29+ // Inject X-GitHub-Api-Version header on every request to suppress the
30+ // "@octokit/request: endpoint is deprecated" warning that fires when the
31+ // unversioned GitHub REST API is used.
32+ githubModule . hook . before ( "request" , options => {
33+ if ( ! options . headers [ "X-GitHub-Api-Version" ] ) {
34+ options . headers [ "X-GitHub-Api-Version" ] = "2022-11-28" ;
35+ }
36+ } ) ;
2937 // @ts -expect-error - Assigning to global properties that are declared as const
3038 // Wrap the github object so every github.rest.*.*() call automatically logs
3139 // x-ratelimit-* headers to github_rate_limits.jsonl for observability.
@@ -35,7 +43,17 @@ function setupGlobals(coreModule, githubModule, contextModule, execModule, ioMod
3543 global . exec = execModule ;
3644 // @ts -expect-error - Assigning to global properties that are declared as const
3745 global . io = ioModule ;
38- global . getOctokit = getOctokitFn ;
46+ // Wrap getOctokit so every client created via global.getOctokit(token) also
47+ // carries X-GitHub-Api-Version, suppressing the deprecation warning for
48+ // per-handler authenticated clients (cross-repo PAT operations, etc.).
49+ global . getOctokit = ( token , options = { } ) =>
50+ getOctokitFn ( token , {
51+ ...options ,
52+ headers : {
53+ "X-GitHub-Api-Version" : "2022-11-28" ,
54+ ...( options . headers || { } ) ,
55+ } ,
56+ } ) ;
3957}
4058
4159module . exports = { setupGlobals } ;
0 commit comments