@@ -1935,13 +1935,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
19351935 return result;
19361936};
19371937Object.defineProperty(exports, "__esModule", { value: true });
1938- exports.getServerUrl = exports.getFetchUrl = void 0;
1938+ exports.isGhes = exports.getServerApiUrl = exports. getServerUrl = exports.getFetchUrl = void 0;
19391939const assert = __importStar(__webpack_require__(357));
19401940const url_1 = __webpack_require__(835);
19411941function getFetchUrl(settings) {
19421942 assert.ok(settings.repositoryOwner, 'settings.repositoryOwner must be defined');
19431943 assert.ok(settings.repositoryName, 'settings.repositoryName must be defined');
1944- const serviceUrl = getServerUrl();
1944+ const serviceUrl = getServerUrl(settings.githubServerUrl );
19451945 const encodedOwner = encodeURIComponent(settings.repositoryOwner);
19461946 const encodedName = encodeURIComponent(settings.repositoryName);
19471947 if (settings.sshKey) {
@@ -1951,13 +1951,27 @@ function getFetchUrl(settings) {
19511951 return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
19521952}
19531953exports.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 );
19591959}
19601960exports.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;
19611975
19621976
19631977/***/ }),
@@ -4066,6 +4080,51 @@ function authenticationPlugin(octokit, options) {
40664080}
40674081
40684082
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+
40694128/***/ }),
40704129
40714130/***/ 197:
@@ -4279,9 +4338,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42794338};
42804339Object.defineProperty(exports, "__esModule", { value: true });
42814340exports.checkCommitInfo = exports.testRef = exports.getRefSpec = exports.getRefSpecForAllHistory = exports.getCheckoutInfo = exports.tagsRefSpec = void 0;
4282- const url_1 = __webpack_require__(835);
42834341const core = __importStar(__webpack_require__(470));
42844342const github = __importStar(__webpack_require__(469));
4343+ const octokit_provider_1 = __webpack_require__(195);
4344+ const url_helper_1 = __webpack_require__(81);
42854345exports.tagsRefSpec = '+refs/tags/*:refs/tags/*';
42864346function getCheckoutInfo(git, ref, commit) {
42874347 return __awaiter(this, void 0, void 0, function* () {
@@ -4431,12 +4491,12 @@ function testRef(git, ref, commit) {
44314491 });
44324492}
44334493exports.testRef = testRef;
4434- function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref, commit) {
4494+ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref, commit, baseUrl ) {
44354495 var _a, _b;
44364496 return __awaiter(this, void 0, void 0, function* () {
44374497 try {
44384498 // GHES?
4439- if (isGhes( )) {
4499+ if ((0, url_helper_1. isGhes)(baseUrl )) {
44404500 return;
44414501 }
44424502 // Auth token?
@@ -4481,7 +4541,8 @@ function checkCommitInfo(token, commitInfo, repositoryOwner, repositoryName, ref
44814541 const actualHeadSha = match[1];
44824542 if (actualHeadSha !== expectedHeadSha) {
44834543 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,
44854546 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})`
44864547 });
44874548 yield octokit.repos.get({ owner: repositoryOwner, repo: repositoryName });
@@ -4507,10 +4568,6 @@ function select(obj, path) {
45074568 const key = path.substr(0, i);
45084569 return select(obj[key], path.substr(i + 1));
45094570}
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- }
45144571
45154572
45164573/***/ }),
@@ -6561,7 +6618,7 @@ class GitAuthHelper {
65616618 this.git = gitCommandManager;
65626619 this.settings = gitSourceSettings || {};
65636620 // Token auth header
6564- const serverUrl = urlHelper.getServerUrl();
6621+ const serverUrl = urlHelper.getServerUrl(this.settings.githubServerUrl );
65656622 this.tokenConfigKey = `http.${serverUrl.origin}/.extraheader`; // "origin" is SCHEME://HOSTNAME[:PORT]
65666623 const basicCredential = Buffer.from(`x-access-token:${this.settings.authToken}`, 'utf8').toString('base64');
65676624 core.setSecret(basicCredential);
@@ -7382,7 +7439,7 @@ function getSource(settings) {
73827439 else if (settings.sshKey) {
73837440 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.`);
73847441 }
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 );
73867443 return;
73877444 }
73887445 // Save state for POST action
@@ -7415,7 +7472,7 @@ function getSource(settings) {
74157472 settings.ref = yield git.getDefaultBranch(repositoryUrl);
74167473 }
74177474 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 );
74197476 }
74207477 core.endGroup();
74217478 }
@@ -7481,7 +7538,7 @@ function getSource(settings) {
74817538 // Log commit sha
74827539 yield git.log1("--format='%H'");
74837540 // 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 );
74857542 }
74867543 finally {
74877544 // Remove auth
@@ -10966,24 +11023,24 @@ exports.getDefaultBranch = exports.downloadRepository = void 0;
1096611023const assert = __importStar(__webpack_require__(357));
1096711024const core = __importStar(__webpack_require__(470));
1096811025const fs = __importStar(__webpack_require__(747));
10969- const github = __importStar(__webpack_require__(469));
1097011026const io = __importStar(__webpack_require__(1));
1097111027const path = __importStar(__webpack_require__(622));
1097211028const retryHelper = __importStar(__webpack_require__(587));
1097311029const toolCache = __importStar(__webpack_require__(533));
1097411030const v4_1 = __importDefault(__webpack_require__(826));
11031+ const octokit_provider_1 = __webpack_require__(195);
1097511032const IS_WINDOWS = process.platform === 'win32';
10976- function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath) {
11033+ function downloadRepository(authToken, owner, repo, ref, commit, repositoryPath, baseUrl ) {
1097711034 return __awaiter(this, void 0, void 0, function* () {
1097811035 // Determine the default branch
1097911036 if (!ref && !commit) {
1098011037 core.info('Determining the default branch');
10981- ref = yield getDefaultBranch(authToken, owner, repo);
11038+ ref = yield getDefaultBranch(authToken, owner, repo, baseUrl );
1098211039 }
1098311040 // Download the archive
1098411041 let archiveData = yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
1098511042 core.info('Downloading the archive');
10986- return yield downloadArchive(authToken, owner, repo, ref, commit);
11043+ return yield downloadArchive(authToken, owner, repo, ref, commit, baseUrl );
1098711044 }));
1098811045 // Write archive to disk
1098911046 core.info('Writing archive to disk');
@@ -11027,12 +11084,12 @@ exports.downloadRepository = downloadRepository;
1102711084/**
1102811085 * Looks up the default branch name
1102911086 */
11030- function getDefaultBranch(authToken, owner, repo) {
11087+ function getDefaultBranch(authToken, owner, repo, baseUrl ) {
1103111088 return __awaiter(this, void 0, void 0, function* () {
1103211089 return yield retryHelper.execute(() => __awaiter(this, void 0, void 0, function* () {
1103311090 var _a;
1103411091 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 } );
1103611093 let result;
1103711094 try {
1103811095 // Get the default branch from the repo info
@@ -11062,9 +11119,9 @@ function getDefaultBranch(authToken, owner, repo) {
1106211119 });
1106311120}
1106411121exports.getDefaultBranch = getDefaultBranch;
11065- function downloadArchive(authToken, owner, repo, ref, commit) {
11122+ function downloadArchive(authToken, owner, repo, ref, commit, baseUrl ) {
1106611123 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 } );
1106811125 const params = {
1106911126 owner: owner,
1107011127 repo: repo,
@@ -17330,6 +17387,9 @@ function getInputs() {
1733017387 // Set safe.directory in git global config.
1733117388 result.setSafeDirectory =
1733217389 (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}`);
1733317393 return result;
1733417394 });
1733517395}
0 commit comments