@@ -1935,13 +1935,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
1935
1935
return result;
1936
1936
};
1937
1937
Object.defineProperty(exports, "__esModule", { value: true });
1938
- exports.getServerUrl = exports.getFetchUrl = void 0;
1938
+ exports.isGhes = exports.getServerApiUrl = exports. getServerUrl = exports.getFetchUrl = void 0;
1939
1939
const assert = __importStar(__webpack_require__(357));
1940
1940
const url_1 = __webpack_require__(835);
1941
1941
function getFetchUrl(settings) {
1942
1942
assert.ok(settings.repositoryOwner, 'settings.repositoryOwner must be defined');
1943
1943
assert.ok(settings.repositoryName, 'settings.repositoryName must be defined');
1944
- const serviceUrl = getServerUrl();
1944
+ const serviceUrl = getServerUrl(settings.githubServerUrl );
1945
1945
const encodedOwner = encodeURIComponent(settings.repositoryOwner);
1946
1946
const encodedName = encodeURIComponent(settings.repositoryName);
1947
1947
if (settings.sshKey) {
@@ -1951,13 +1951,27 @@ function getFetchUrl(settings) {
1951
1951
return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
1952
1952
}
1953
1953
exports.getFetchUrl = getFetchUrl;
1954
- function getServerUrl() {
1955
- // todo: remove GITHUB_URL after support for GHES Alpha is no longer needed
1956
- return new url_1.URL(process.env['GITHUB_SERVER_URL'] ||
1957
- process.env['GITHUB_URL '] ||
1958
- 'https://github.com' );
1954
+ function getServerUrl(url ) {
1955
+ let urlValue = url && url.trim().length > 0
1956
+ ? url
1957
+ : process.env['GITHUB_SERVER_URL '] || 'https://github.com';
1958
+ return new url_1.URL(urlValue );
1959
1959
}
1960
1960
exports.getServerUrl = getServerUrl;
1961
+ function getServerApiUrl(url) {
1962
+ let apiUrl = 'https://api.github.com';
1963
+ if (isGhes(url)) {
1964
+ const serverUrl = getServerUrl(url);
1965
+ apiUrl = new url_1.URL(`${serverUrl.origin}/api/v3`).toString();
1966
+ }
1967
+ return apiUrl;
1968
+ }
1969
+ exports.getServerApiUrl = getServerApiUrl;
1970
+ function isGhes(url) {
1971
+ const ghUrl = getServerUrl(url);
1972
+ return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
1973
+ }
1974
+ exports.isGhes = isGhes;
1961
1975
1962
1976
1963
1977
/***/ }),
@@ -4066,6 +4080,51 @@ function authenticationPlugin(octokit, options) {
4066
4080
}
4067
4081
4068
4082
4083
+ /***/ }),
4084
+
4085
+ /***/ 195:
4086
+ /***/ (function(__unusedmodule, exports, __webpack_require__) {
4087
+
4088
+ "use strict";
4089
+
4090
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4091
+ if (k2 === undefined) k2 = k;
4092
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4093
+ }) : (function(o, m, k, k2) {
4094
+ if (k2 === undefined) k2 = k;
4095
+ o[k2] = m[k];
4096
+ }));
4097
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
4098
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
4099
+ }) : function(o, v) {
4100
+ o["default"] = v;
4101
+ });
4102
+ var __importStar = (this && this.__importStar) || function (mod) {
4103
+ if (mod && mod.__esModule) return mod;
4104
+ var result = {};
4105
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
4106
+ __setModuleDefault(result, mod);
4107
+ return result;
4108
+ };
4109
+ Object.defineProperty(exports, "__esModule", { value: true });
4110
+ exports.getOctokit = exports.Octokit = void 0;
4111
+ const github = __importStar(__webpack_require__(469));
4112
+ const url_helper_1 = __webpack_require__(81);
4113
+ // Centralize all Octokit references by re-exporting
4114
+ var rest_1 = __webpack_require__(0);
4115
+ Object.defineProperty(exports, "Octokit", { enumerable: true, get: function () { return rest_1.Octokit; } });
4116
+ function getOctokit(authToken, opts) {
4117
+ const options = {
4118
+ baseUrl: (0, url_helper_1.getServerApiUrl)(opts.baseUrl)
4119
+ };
4120
+ if (opts.userAgent) {
4121
+ options.userAgent = opts.userAgent;
4122
+ }
4123
+ return new github.GitHub(authToken, options);
4124
+ }
4125
+ exports.getOctokit = getOctokit;
4126
+
4127
+
4069
4128
/***/ }),
4070
4129
4071
4130
/***/ 197:
@@ -4279,9 +4338,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
4279
4338
};
4280
4339
Object.defineProperty(exports, "__esModule", { value: true });
4281
4340
exports.checkCommitInfo = exports.testRef = exports.getRefSpec = exports.getRefSpecForAllHistory = exports.getCheckoutInfo = exports.tagsRefSpec = void 0;
4282
- const url_1 = __webpack_require__(835);
4283
4341
const core = __importStar(__webpack_require__(470));
4284
4342
const github = __importStar(__webpack_require__(469));
4343
+ const octokit_provider_1 = __webpack_require__(195);
4344
+ const url_helper_1 = __webpack_require__(81);
4285
4345
exports.tagsRefSpec = '+refs/tags/*:refs/tags/*';
4286
4346
function getCheckoutInfo(git, ref, commit) {
4287
4347
return __awaiter(this, void 0, void 0, function* () {
@@ -4431,12 +4491,12 @@ function testRef(git, ref, commit) {
4431
4491
});
4432
4492
}
4433
4493
exports.testRef = testRef;
4434
- function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref, commit) {
4494
+ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref, commit, baseUrl ) {
4435
4495
var _a, _b;
4436
4496
return __awaiter(this, void 0, void 0, function* () {
4437
4497
try {
4438
4498
// GHES?
4439
- if (isGhes( )) {
4499
+ if ((0, url_helper_1. isGhes)(baseUrl )) {
4440
4500
return;
4441
4501
}
4442
4502
// Auth token?
@@ -4481,7 +4541,8 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
4481
4541
const actualHeadSha = match[1];
4482
4542
if (actualHeadSha !== expectedHeadSha) {
4483
4543
core.debug(`Expected head sha ${expectedHeadSha}; actual head sha ${actualHeadSha}`);
4484
- const octokit = new github.GitHub(token, {
4544
+ const octokit = (0, octokit_provider_1.getOctokit)(token, {
4545
+ baseUrl: baseUrl,
4485
4546
userAgent: `actions-checkout-tracepoint/1.0 (code=STALE_MERGE;owner=${repositoryOwner};repo=${repositoryName};pr=${fromPayload('number')};run_id=${process.env['GITHUB_RUN_ID']};expected_head_sha=${expectedHeadSha};actual_head_sha=${actualHeadSha})`
4486
4547
});
4487
4548
yield octokit.repos.get({ owner: repositoryOwner, repo: repositoryName });
@@ -4507,10 +4568,6 @@ function select(obj, path) {
4507
4568
const key = path.substr(0, i);
4508
4569
return select(obj[key], path.substr(i + 1));
4509
4570
}
4510
- function isGhes() {
4511
- const ghUrl = new url_1.URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
4512
- return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM';
4513
- }
4514
4571
4515
4572
4516
4573
/***/ }),
@@ -6561,7 +6618,7 @@ class GitAuthHelper {
6561
6618
this.git = gitCommandManager;
6562
6619
this.settings = gitSourceSettings || {};
6563
6620
// Token auth header
6564
- const serverUrl = urlHelper.getServerUrl();
6621
+ const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl );
6565
6622
this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader`; // "origin" is SCHEME://HOSTNAME[:PORT]
6566
6623
const basicCredential = Buffer.from(`x-access-token:${this.settings.authToken}`, 'utf8').toString('base64');
6567
6624
core.setSecret(basicCredential);
@@ -7382,7 +7439,7 @@ function getSource(settings) {
7382
7439
else if (settings.sshKey) {
7383
7440
throw new Error(`Input 'ssh-key' not supported when falling back to download using the GitHub REST API. To create a local Git repository instead, add Git ${gitCommandManager.MinimumGitVersion} or higher to the PATH.`);
7384
7441
}
7385
- yield githubApiHelper.downloadRepository(settings.authToken, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit, settings.repositoryPath);
7442
+ yield githubApiHelper.downloadRepository(settings.authToken, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit, settings.repositoryPath, settings.githubServerUrl );
7386
7443
return;
7387
7444
}
7388
7445
// Save state for POST action
@@ -7415,7 +7472,7 @@ function getSource(settings) {
7415
7472
settings.ref = yield git.getDefaultBranch(repositoryUrl);
7416
7473
}
7417
7474
else {
7418
- settings.ref = yield githubApiHelper.getDefaultBranch(settings.authToken, settings.repositoryOwner, settings.repositoryName);
7475
+ settings.ref = yield githubApiHelper.getDefaultBranch(settings.authToken, settings.repositoryOwner, settings.repositoryName, settings.githubServerUrl );
7419
7476
}
7420
7477
core.endGroup();
7421
7478
}
@@ -7481,7 +7538,7 @@ function getSource(settings) {
7481
7538
// Log commit sha
7482
7539
yield git.log1("--format='%H'");
7483
7540
// Check for incorrect pull request merge commit
7484
- yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit);
7541
+ yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit, settings.githubServerUrl );
7485
7542
}
7486
7543
finally {
7487
7544
// Remove auth
@@ -10966,24 +11023,24 @@ exports.getDefaultBranch = exports.downloadRepository = void 0;
10966
11023
const assert = __importStar(__webpack_require__(357));
10967
11024
const core = __importStar(__webpack_require__(470));
10968
11025
const fs = __importStar(__webpack_require__(747));
10969
- const github = __importStar(__webpack_require__(469));
10970
11026
const io = __importStar(__webpack_require__(1));
10971
11027
const path = __importStar(__webpack_require__(622));
10972
11028
const retryHelper = __importStar(__webpack_require__(587));
10973
11029
const toolCache = __importStar(__webpack_require__(533));
10974
11030
const v4_1 = __importDefault(__webpack_require__(826));
11031
+ const octokit_provider_1 = __webpack_require__(195);
10975
11032
const IS_WINDOWS = process.platform === 'win32';
10976
- function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath) {
11033
+ function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl ) {
10977
11034
return __awaiter(this, void 0, void 0, function* () {
10978
11035
// Determine the default branch
10979
11036
if (!ref && !commit) {
10980
11037
core.info('Determining the default branch');
10981
- ref = yield getDefaultBranch(authToken, owner, repo);
11038
+ ref = yield getDefaultBranch(authToken, owner, repo, baseUrl );
10982
11039
}
10983
11040
// Download the archive
10984
11041
let archiveData = yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
10985
11042
core.info('Downloading the archive');
10986
- return yield downloadArchive(authToken, owner, repo, ref, commit);
11043
+ return yield downloadArchive(authToken, owner, repo, ref, commit, baseUrl );
10987
11044
}));
10988
11045
// Write archive to disk
10989
11046
core.info('Writing archive to disk');
@@ -11027,12 +11084,12 @@ exports.downloadRepository = downloadRepository;
11027
11084
/**
11028
11085
* Looks up the default branch name
11029
11086
*/
11030
- function getDefaultBranch(authToken, owner, repo) {
11087
+ function getDefaultBranch(authToken, owner, repo, baseUrl ) {
11031
11088
return __awaiter(this, void 0, void 0, function* () {
11032
11089
return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
11033
11090
var _a;
11034
11091
core.info('Retrieving the default branch name');
11035
- const octokit = new github.GitHub (authToken);
11092
+ const octokit = (0, octokit_provider_1.getOctokit) (authToken, { baseUrl: baseUrl } );
11036
11093
let result;
11037
11094
try {
11038
11095
// Get the default branch from the repo info
@@ -11062,9 +11119,9 @@ function getDefaultBranch(authToken, owner, repo) {
11062
11119
});
11063
11120
}
11064
11121
exports.getDefaultBranch = getDefaultBranch;
11065
- function downloadArchive(authToken, owner, repo, ref, commit) {
11122
+ function downloadArchive(authToken, owner, repo, ref, commit, baseUrl ) {
11066
11123
return __awaiter(this, void 0, void 0, function* () {
11067
- const octokit = new github.GitHub (authToken);
11124
+ const octokit = (0, octokit_provider_1.getOctokit) (authToken, { baseUrl: baseUrl } );
11068
11125
const params = {
11069
11126
owner: owner,
11070
11127
repo: repo,
@@ -17330,6 +17387,9 @@ function getInputs() {
17330
17387
// Set safe.directory in git global config.
17331
17388
result.setSafeDirectory =
17332
17389
(core.getInput('set-safe-directory') || 'true').toUpperCase() === 'TRUE';
17390
+ // Determine the GitHub URL that the repository is being hosted from
17391
+ result.githubServerUrl = core.getInput('github-server-url');
17392
+ core.debug(`GitHub Host URL = ${result.githubServerUrl}`);
17333
17393
return result;
17334
17394
});
17335
17395
}
0 commit comments