Update dependencies in github package (#1553)

* Update octokit package

* define type for function

* fix linter

* Update github package to latest

* Update RELEASES.md
This commit is contained in:
Tatyana Kostromskaya
2023-10-10 16:04:42 +02:00
committed by GitHub
parent 797f48fcfa
commit 494f12bcd9
8 changed files with 349 additions and 351 deletions

View File

@@ -1,6 +1,7 @@
import * as http from 'http'
import * as httpClient from '@actions/http-client'
import {OctokitOptions} from '@octokit/core/dist-types/types'
import {ProxyAgent, fetch} from 'undici'
export function getAuthString(
token: string,
@@ -20,6 +21,24 @@ export function getProxyAgent(destinationUrl: string): http.Agent {
return hc.getAgent(destinationUrl)
}
export function getProxyAgentDispatcher(
destinationUrl: string
): ProxyAgent | undefined {
const hc = new httpClient.HttpClient()
return hc.getAgentDispatcher(destinationUrl)
}
export function getProxyFetch(destinationUrl): typeof fetch {
const httpDispatcher = getProxyAgentDispatcher(destinationUrl)
const proxyFetch: typeof fetch = async (url, opts) => {
return fetch(url, {
...opts,
dispatcher: httpDispatcher
})
}
return proxyFetch
}
export function getApiBaseUrl(): string {
return process.env['GITHUB_API_URL'] || 'https://api.github.com'
}

View File

@@ -13,7 +13,8 @@ const baseUrl = Utils.getApiBaseUrl()
export const defaults: OctokitOptions = {
baseUrl,
request: {
agent: Utils.getProxyAgent(baseUrl)
agent: Utils.getProxyAgent(baseUrl),
fetch: Utils.getProxyFetch(baseUrl)
}
}