File tree Expand file tree Collapse file tree 8 files changed +34737
-67
lines changed Expand file tree Collapse file tree 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" ;
12import { 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 */
233
334export default request . defaults ( {
435 headers : {
536 "user-agent" : "actions/create-github-app-token" ,
637 } ,
38+ baseUrl,
39+ /* c8 ignore next */
40+ request : proxyUrl ? { fetch : proxyFetch } : { } ,
741} ) ;
Original file line number Diff line number Diff line change @@ -31,16 +31,14 @@ const skipTokenRevoke = Boolean(
3131 core . getInput ( "skip-token-revoke" ) || core . getInput ( "skip_token_revoke" )
3232) ;
3333
34- const baseUrl = core . getInput ( "github-api-url" ) . replace ( / \/ $ / , "" ) ;
35-
3634main (
3735 appId ,
3836 privateKey ,
3937 owner ,
4038 repositories ,
4139 core ,
4240 createAppAuth ,
43- request . defaults ( { baseUrl } ) ,
41+ request ,
4442 skipTokenRevoke
4543) . catch ( ( error ) => {
4644 /* c8 ignore next 3 */
Original file line number Diff line number Diff line change 1515 "@actions/core" : " ^1.10.1" ,
1616 "@octokit/auth-app" : " ^6.0.3" ,
1717 "@octokit/request" : " ^8.1.6" ,
18- "p-retry" : " ^6.2.0"
18+ "p-retry" : " ^6.2.0" ,
19+ "undici" : " ^6.6.0"
1920 },
2021 "devDependencies" : {
2122 "@sinonjs/fake-timers" : " ^11.2.2" ,
2526 "esbuild" : " ^0.20.0" ,
2627 "execa" : " ^8.0.1" ,
2728 "open-cli" : " ^8.0.0" ,
28- "undici" : " ^6.6.0" ,
2929 "yaml" : " ^2.3.4"
3030 },
3131 "release" : {
Original file line number Diff line number Diff line change @@ -5,9 +5,7 @@ import core from "@actions/core";
55import { post } from "./lib/post.js" ;
66import request from "./lib/request.js" ;
77
8- const baseUrl = core . getInput ( "github-api-url" ) . replace ( / \/ $ / , "" ) ;
9-
10- post ( core , request . defaults ( { baseUrl } ) ) . catch ( ( error ) => {
8+ post ( core , request ) . catch ( ( error ) => {
119 /* c8 ignore next 3 */
1210 console . error ( error ) ;
1311 core . setFailed ( error . message ) ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export const DEFAULT_ENV = {
66 GITHUB_REPOSITORY_OWNER : "actions" ,
77 GITHUB_REPOSITORY : "actions/create-github-app-token" ,
88 // 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
1010 "INPUT_GITHUB-API-URL" : "https://api.github.com" ,
1111 "INPUT_APP-ID" : "123456" ,
1212 // 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