Compare commits
1 commit
7174d368c2
...
2c60f35176
Author | SHA1 | Date | |
---|---|---|---|
2c60f35176 |
2 changed files with 7 additions and 9 deletions
15
dist/index.js
vendored
15
dist/index.js
vendored
|
@ -405,7 +405,7 @@ function createPullRequest(inputs) {
|
|||
core.startGroup('Determining the base and head repositories');
|
||||
const baseRemote = gitConfigHelper.getGitRemote();
|
||||
// Init the GitHub clients
|
||||
const apiUrl = yield github_helper_1.GitHubHelper.determineApiUrl(baseRemote.hostname);
|
||||
const apiUrl = yield github_helper_1.GitHubHelper.determineApiPath(baseRemote.hostname);
|
||||
core.info(`Using API base URL: ${apiUrl}`);
|
||||
const ghBranch = new github_helper_1.GitHubHelper(apiUrl, inputs.branchToken);
|
||||
const ghPull = new github_helper_1.GitHubHelper(apiUrl, inputs.token);
|
||||
|
@ -1289,7 +1289,7 @@ class GitHubHelper {
|
|||
options.throttle = octokit_client_1.throttleOptions;
|
||||
this.octokit = new octokit_client_1.Octokit(options);
|
||||
}
|
||||
static determineApiUrl(hostname) {
|
||||
static determineApiPath(hostname) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (hostname === 'github.com') {
|
||||
return "https://api.github.com";
|
||||
|
@ -1299,14 +1299,11 @@ class GitHubHelper {
|
|||
for (const path of possiblePaths) {
|
||||
try {
|
||||
const url = `${baseUrl}${path}`;
|
||||
const response = yield fetch(url, { method: 'GET', redirect: 'manual' }); // GitLab redirects
|
||||
// invalid API paths
|
||||
// to login prompt
|
||||
// which returns 200
|
||||
const response = yield fetch(url, { method: 'GET', redirect: 'manual' });
|
||||
const contentType = response.headers.get('Content-Type') || '';
|
||||
if ((response.ok || [401, 403].includes(response.status)) && // We might get 401, 403
|
||||
// as we're unauthorised
|
||||
contentType.includes('application/json')) {
|
||||
if ((response.ok || [401, 403].includes(response.status)) && // Check for valid API status codes
|
||||
contentType.includes('application/json') // Ensure it's returning JSON
|
||||
) {
|
||||
return path.includes('/version') ? url.replace('/version', '') : url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,3 +432,4 @@ export class GitHubHelper {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue