e715b04a11
When proxy environment variables (https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY) are detected and NODE_USE_ENV_PROXY is not already set to "1", the action spawns a child process with NODE_USE_ENV_PROXY=1 to enable Node.js native proxy support. - Add lib/run-with-proxy.js shared utility for both main.js and post.js - Update main.js and post.js to use runWithProxy() wrapper - Add tests for proxy spawning, child error handling, and already-enabled path - 100% code coverage maintained Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
// @ts-check
|
|
|
|
import core from "@actions/core";
|
|
import { createAppAuth } from "@octokit/auth-app";
|
|
|
|
import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js";
|
|
import { main } from "./lib/main.js";
|
|
import request from "./lib/request.js";
|
|
import { runWithProxy } from "./lib/run-with-proxy.js";
|
|
|
|
if (!process.env.GITHUB_REPOSITORY) {
|
|
throw new Error("GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'");
|
|
}
|
|
|
|
if (!process.env.GITHUB_REPOSITORY_OWNER) {
|
|
throw new Error("GITHUB_REPOSITORY_OWNER missing, must be set to '<owner>'");
|
|
}
|
|
|
|
// Export promise for testing
|
|
export default runWithProxy(async () => {
|
|
const appId = core.getInput("app-id");
|
|
const privateKey = core.getInput("private-key");
|
|
const owner = core.getInput("owner");
|
|
const repositories = core
|
|
.getInput("repositories")
|
|
.split(/[\n,]+/)
|
|
.map((s) => s.trim())
|
|
.filter((x) => x !== "");
|
|
|
|
const skipTokenRevoke = core.getBooleanInput("skip-token-revoke");
|
|
|
|
const permissions = getPermissionsFromInputs(process.env);
|
|
|
|
return main(
|
|
appId,
|
|
privateKey,
|
|
owner,
|
|
repositories,
|
|
permissions,
|
|
core,
|
|
createAppAuth,
|
|
request,
|
|
skipTokenRevoke,
|
|
).catch((error) => {
|
|
/* c8 ignore next 3 */
|
|
console.error(error);
|
|
core.setFailed(error.message);
|
|
});
|
|
});
|