|
9 | 9 | fetch as undiciFetch, |
10 | 10 | } from "undici"; |
11 | 11 |
|
| 12 | +import type { ActionState } from "./action-common"; |
12 | 13 | import { getActionVersion, getRequiredInput } from "./actions-util"; |
13 | 14 | import { |
14 | 15 | ActionsEnvVars, |
@@ -60,14 +61,16 @@ export interface GitHubApiExternalRepoDetails { |
60 | 61 | * Gets the configuration for the private registry authentication proxy, |
61 | 62 | * if it is available in the environment. |
62 | 63 | * |
63 | | - * @param env The environment to query for the proxy host and port. |
| 64 | + * @param action The required Action state. |
64 | 65 | * @returns A `ProxyAgent` corresponding to the private registry proxy, |
65 | 66 | * or `undefined` if we couldn't retrieve the host and port. |
66 | 67 | */ |
67 | | -export function getRegistryProxy(env: ReadOnlyEnv): ProxyAgent | undefined { |
68 | | - const host = env.getOptional(RegistryProxyVars.PROXY_HOST); |
69 | | - const port = env.getOptional(RegistryProxyVars.PROXY_PORT); |
70 | | - const cert = env.getOptional(RegistryProxyVars.PROXY_CA_CERTIFICATE); |
| 68 | +export function getRegistryProxy( |
| 69 | + action: ActionState<["Env"]>, |
| 70 | +): ProxyAgent | undefined { |
| 71 | + const host = action.env.getOptional(RegistryProxyVars.PROXY_HOST); |
| 72 | + const port = action.env.getOptional(RegistryProxyVars.PROXY_PORT); |
| 73 | + const cert = action.env.getOptional(RegistryProxyVars.PROXY_CA_CERTIFICATE); |
71 | 74 |
|
72 | 75 | if (host && port) { |
73 | 76 | return new ProxyAgent({ |
@@ -102,10 +105,10 @@ export function makeProxyRequestOptions( |
102 | 105 | * This will run API requests through the private registry authentication proxy |
103 | 106 | * if it is configured. |
104 | 107 | * |
105 | | - * @param env The environment to query for the proxy host and port. |
| 108 | + * @param action The required Action state. |
106 | 109 | */ |
107 | | -export function getApiFetch(env: ReadOnlyEnv): typeof undiciFetch { |
108 | | - const dispatcher = getRegistryProxy(env); |
| 110 | +export function getApiFetch(action: ActionState<["Env"]>): typeof undiciFetch { |
| 111 | + const dispatcher = getRegistryProxy(action); |
109 | 112 |
|
110 | 113 | const proxiedFetch = (req: RequestInfo, init?: RequestInit) => { |
111 | 114 | return undiciFetch(req, { ...init, dispatcher }); |
|
0 commit comments