diff --git a/lib/request.js b/lib/request.js index e68566d..f35d330 100644 --- a/lib/request.js +++ b/lib/request.js @@ -1,41 +1,11 @@ import * as core from "@actions/core"; import { request } from "@octokit/request"; -import { ProxyAgent, fetch as undiciFetch } from "undici"; +// Get the GitHub API URL from the action input and remove any trailing slash const baseUrl = core.getInput("github-api-url").replace(/\/$/, ""); -// https://docs.github.com/actions/hosting-your-own-runners/managing-self-hosted-runners/using-a-proxy-server-with-self-hosted-runners -const proxyUrl = - process.env.https_proxy || - process.env.HTTPS_PROXY || - process.env.http_proxy || - process.env.HTTP_PROXY; - -/* c8 ignore start */ -// Native support for proxies in Undici is under consideration: https://github.com/nodejs/undici/issues/1650 -// Until then, we need to use a custom fetch function to add proxy support. -const proxyFetch = (url, options) => { - const urlHost = new URL(url).hostname; - const noProxy = (process.env.no_proxy || process.env.NO_PROXY || "").split( - ",", - ); - - if (!noProxy.includes(urlHost)) { - options = { - ...options, - dispatcher: new ProxyAgent(String(proxyUrl)), - }; - } - - return undiciFetch(url, options); -}; -/* c8 ignore stop */ - +// Configure the default settings for GitHub API requests export default request.defaults({ - headers: { - "user-agent": "actions/create-github-app-token", - }, + headers: { "user-agent": "actions/create-github-app-token" }, baseUrl, - /* c8 ignore next */ - request: proxyUrl ? { fetch: proxyFetch } : {}, }); diff --git a/package.json b/package.json index dae3b18..fd96e2d 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,7 @@ "@actions/core": "^3.0.0", "@octokit/auth-app": "^8.2.0", "@octokit/request": "^10.0.8", - "p-retry": "^7.1.1", - "undici": "^7.24.1" + "p-retry": "^7.1.1" }, "devDependencies": { "@octokit/openapi": "^21.0.0", @@ -31,6 +30,7 @@ "esbuild": "^0.27.3", "execa": "^9.6.1", "open-cli": "^8.0.0", + "undici": "^7.24.1", "yaml": "^2.8.2" }, "release": { diff --git a/tests/snapshots/index.js.snap b/tests/snapshots/index.js.snap index 773f4b1..e66c3d5 100644 Binary files a/tests/snapshots/index.js.snap and b/tests/snapshots/index.js.snap differ