fix: remove custom proxy handling (#143)

Undici has added native support for proxy handling, so it is no longer necessary for us to have our own custom proxy handling.

Reverts #102 and resolves #134.
This commit is contained in:
Parker Brown
2025-08-22 12:16:16 -07:00
committed by GitHub
parent 2ae58da528
commit cda91bf2b9
6 changed files with 170 additions and 42861 deletions
+81 -21412
View File
File diff suppressed because one or more lines are too long
+81 -21412
View File
File diff suppressed because one or more lines are too long
+3 -33
View File
@@ -1,41 +1,11 @@
import 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 } : {},
});
+3 -2
View File
@@ -12,8 +12,7 @@
"@actions/core": "^1.11.1",
"@octokit/auth-app": "^7.2.1",
"@octokit/request": "^9.2.2",
"p-retry": "^6.2.1",
"undici": "^7.8.0"
"p-retry": "^6.2.1"
},
"devDependencies": {
"@octokit/openapi": "^19.1.0",
@@ -24,6 +23,7 @@
"esbuild": "^0.25.8",
"execa": "^9.6.0",
"open-cli": "^8.0.0",
"undici": "^7.13.0",
"yaml": "^2.8.1"
},
"engines": {
@@ -3817,6 +3817,7 @@
"version": "7.13.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-7.13.0.tgz",
"integrity": "sha512-l+zSMssRqrzDcb3fjMkjjLGmuiiK2pMIcV++mJaAc9vhjSGpvM7h43QgP+OAMb1GImHmbPyG2tBXeuyG5iY4gA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=20.18.1"
+2 -2
View File
@@ -18,8 +18,7 @@
"@actions/core": "^1.11.1",
"@octokit/auth-app": "^7.2.1",
"@octokit/request": "^9.2.2",
"p-retry": "^6.2.1",
"undici": "^7.8.0"
"p-retry": "^6.2.1"
},
"devDependencies": {
"@octokit/openapi": "^19.1.0",
@@ -30,6 +29,7 @@
"esbuild": "^0.25.8",
"execa": "^9.6.0",
"open-cli": "^8.0.0",
"undici": "^7.13.0",
"yaml": "^2.8.1"
},
"release": {
Binary file not shown.