File tree 8 files changed +34737
-67
lines changed
8 files changed +34737
-67
lines changed Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ import core from "@actions/core" ;
1
2
import { request } from "@octokit/request" ;
3
+ import { ProxyAgent , fetch as undiciFetch } from "undici" ;
4
+
5
+ const baseUrl = core . getInput ( "github-api-url" ) . replace ( / \/ $ / , "" ) ;
6
+
7
+ // https://docs.github.com/actions/hosting-your-own-runners/managing-self-hosted-runners/using-a-proxy-server-with-self-hosted-runners
8
+ const proxyUrl =
9
+ process . env . https_proxy ||
10
+ process . env . HTTPS_PROXY ||
11
+ process . env . http_proxy ||
12
+ process . env . HTTP_PROXY ;
13
+
14
+ /* c8 ignore start */
15
+ // Native support for proxies in Undici is under consideration: https://github.com/nodejs/undici/issues/1650
16
+ // Until then, we need to use a custom fetch function to add proxy support.
17
+ const proxyFetch = ( url , options ) => {
18
+ const urlHost = new URL ( url ) . hostname ;
19
+ const noProxy = ( process . env . no_proxy || process . env . NO_PROXY || "" ) . split (
20
+ ","
21
+ ) ;
22
+
23
+ if ( ! noProxy . includes ( urlHost ) ) {
24
+ options = {
25
+ ...options ,
26
+ dispatcher : new ProxyAgent ( String ( proxyUrl ) ) ,
27
+ } ;
28
+ }
29
+
30
+ return undiciFetch ( url , options ) ;
31
+ } ;
32
+ /* c8 ignore stop */
2
33
3
34
export default request . defaults ( {
4
35
headers : {
5
36
"user-agent" : "actions/create-github-app-token" ,
6
37
} ,
38
+ baseUrl,
39
+ /* c8 ignore next */
40
+ request : proxyUrl ? { fetch : proxyFetch } : { } ,
7
41
} ) ;
Original file line number Diff line number Diff line change @@ -31,16 +31,14 @@ const skipTokenRevoke = Boolean(
31
31
core . getInput ( "skip-token-revoke" ) || core . getInput ( "skip_token_revoke" )
32
32
) ;
33
33
34
- const baseUrl = core . getInput ( "github-api-url" ) . replace ( / \/ $ / , "" ) ;
35
-
36
34
main (
37
35
appId ,
38
36
privateKey ,
39
37
owner ,
40
38
repositories ,
41
39
core ,
42
40
createAppAuth ,
43
- request . defaults ( { baseUrl } ) ,
41
+ request ,
44
42
skipTokenRevoke
45
43
) . catch ( ( error ) => {
46
44
/* c8 ignore next 3 */
Original file line number Diff line number Diff line change 15
15
"@actions/core" : " ^1.10.1" ,
16
16
"@octokit/auth-app" : " ^6.0.3" ,
17
17
"@octokit/request" : " ^8.1.6" ,
18
- "p-retry" : " ^6.2.0"
18
+ "p-retry" : " ^6.2.0" ,
19
+ "undici" : " ^6.6.0"
19
20
},
20
21
"devDependencies" : {
21
22
"@sinonjs/fake-timers" : " ^11.2.2" ,
25
26
"esbuild" : " ^0.20.0" ,
26
27
"execa" : " ^8.0.1" ,
27
28
"open-cli" : " ^8.0.0" ,
28
- "undici" : " ^6.6.0" ,
29
29
"yaml" : " ^2.3.4"
30
30
},
31
31
"release" : {
Original file line number Diff line number Diff line change @@ -5,9 +5,7 @@ import core from "@actions/core";
5
5
import { post } from "./lib/post.js" ;
6
6
import request from "./lib/request.js" ;
7
7
8
- const baseUrl = core . getInput ( "github-api-url" ) . replace ( / \/ $ / , "" ) ;
9
-
10
- post ( core , request . defaults ( { baseUrl } ) ) . catch ( ( error ) => {
8
+ post ( core , request ) . catch ( ( error ) => {
11
9
/* c8 ignore next 3 */
12
10
console . error ( error ) ;
13
11
core . setFailed ( error . message ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export const DEFAULT_ENV = {
6
6
GITHUB_REPOSITORY_OWNER : "actions" ,
7
7
GITHUB_REPOSITORY : "actions/create-github-app-token" ,
8
8
// inputs are set as environment variables with the prefix INPUT_
9
- // https://docs.github.com/en/ actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
9
+ // https://docs.github.com/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs
10
10
"INPUT_GITHUB-API-URL" : "https://api.github.com" ,
11
11
"INPUT_APP-ID" : "123456" ,
12
12
// This key is invalidated. It’s from https://github.com/octokit/auth-app.js/issues/465#issuecomment-1564998327.
You can’t perform that action at this time.
0 commit comments