File tree 2 files changed +31
-2
lines changed
2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,28 @@ describe('apiURL', () => {
85
85
} ) ;
86
86
} ) ;
87
87
88
+ describe ( 'isGHES' , ( ) => {
89
+ afterEach ( ( ) => {
90
+ process . env . GITHUB_SERVER_URL = '' ;
91
+ } ) ;
92
+ it ( 'should return false when the request domain is github.com' , ( ) => {
93
+ process . env . GITHUB_SERVER_URL = 'https://github.com' ;
94
+ expect ( GitHub . isGHES ) . toBe ( false ) ;
95
+ } ) ;
96
+ it ( 'should return false when the request domain ends with ghe.com' , ( ) => {
97
+ process . env . GITHUB_SERVER_URL = 'https://my.domain.ghe.com' ;
98
+ expect ( GitHub . isGHES ) . toBe ( false ) ;
99
+ } ) ;
100
+ it ( 'should return false when the request domain ends with ghe.localhost' , ( ) => {
101
+ process . env . GITHUB_SERVER_URL = 'https://my.domain.ghe.localhost' ;
102
+ expect ( GitHub . isGHES ) . toBe ( false ) ;
103
+ } ) ;
104
+ it ( 'should return true when the request domain is specific to an enterprise' , ( ) => {
105
+ process . env . GITHUB_SERVER_URL = 'https://my-enterprise.github.com' ;
106
+ expect ( GitHub . isGHES ) . toBe ( true ) ;
107
+ } ) ;
108
+ } ) ;
109
+
88
110
describe ( 'repository' , ( ) => {
89
111
it ( 'returns GitHub repository' , async ( ) => {
90
112
expect ( GitHub . repository ) . toEqual ( 'docker/actions-toolkit' ) ;
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import os from 'os';
22
22
import path from 'path' ;
23
23
import { CreateArtifactRequest , FinalizeArtifactRequest , StringValue } from '@actions/artifact/lib/generated' ;
24
24
import { internalArtifactTwirpClient } from '@actions/artifact/lib/internal/shared/artifact-twirp-client' ;
25
- import { isGhes } from '@actions/artifact/lib/internal/shared/config' ;
26
25
import { getBackendIdsFromToken } from '@actions/artifact/lib/internal/shared/util' ;
27
26
import { getExpiration } from '@actions/artifact/lib/internal/upload/retention' ;
28
27
import { InvalidResponseError , NetworkError } from '@actions/artifact' ;
@@ -67,6 +66,14 @@ export class GitHub {
67
66
return process . env . GITHUB_API_URL || 'https://api.github.com' ;
68
67
}
69
68
69
+ static get isGHES ( ) : boolean {
70
+ const serverURL = new URL ( GitHub . serverURL ) ;
71
+ const hostname = serverURL . hostname . trimEnd ( ) . toUpperCase ( ) ;
72
+ const isGitHubHost = hostname === 'GITHUB.COM' ;
73
+ const isGHESHost = hostname . endsWith ( '.GHE.COM' ) || hostname . endsWith ( '.GHE.LOCALHOST' ) ;
74
+ return ! isGitHubHost && ! isGHESHost ;
75
+ }
76
+
70
77
static get repository ( ) : string {
71
78
return `${ github . context . repo . owner } /${ github . context . repo . repo } ` ;
72
79
}
@@ -124,7 +131,7 @@ export class GitHub {
124
131
}
125
132
126
133
public static async uploadArtifact ( opts : UploadArtifactOpts ) : Promise < UploadArtifactResponse > {
127
- if ( isGhes ( ) ) {
134
+ if ( GitHub . isGHES ) {
128
135
throw new Error ( '@actions/artifact v2.0.0+ is currently not supported on GHES.' ) ;
129
136
}
130
137
You can’t perform that action at this time.
0 commit comments