feat: update logic of getting json file

This commit is contained in:
Ivan Zosimov 2023-09-18 15:53:34 +02:00
parent 3888c0a066
commit cf4e1422a0
2 changed files with 30 additions and 5 deletions

14
dist/setup/index.js vendored
View File

@ -102683,8 +102683,18 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
return __awaiter(this, void 0, void 0, function* () {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
const availableVersionsUrl = 'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl)).result;
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const owner = 'dragonwell-releng';
const repository = 'dragonwell-setup-java';
const branch = 'main';
const filePath = 'releases.json';
const availableVersionsUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
const headers = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
const fetchedDragonwellVersions = (yield this.http.getJson(availableVersionsUrl, headers)).result;
if (!fetchedDragonwellVersions) {
throw new Error(`Couldn't fetch any dragonwell versions from ${availableVersionsUrl}`);
}

View File

@ -4,6 +4,7 @@ import semver from 'semver';
import fs from 'fs';
import path from 'path';
import {OutgoingHttpHeaders} from 'http';
import {JavaBase} from '../base-installer';
import {
@ -61,11 +62,25 @@ export class DragonwellDistribution extends JavaBase {
const platform = this.getPlatformOption();
const arch = this.distributionArchitecture();
const availableVersionsUrl =
'https://raw.githubusercontent.com/dragonwell-releng/dragonwell-setup-java/main/releases.json';
const token = core.getInput('token');
const auth = !token ? undefined : `token ${token}`;
const owner = 'dragonwell-releng';
const repository = 'dragonwell-setup-java';
const branch = 'main';
const filePath = 'releases.json';
const availableVersionsUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
const headers: OutgoingHttpHeaders = {
authorization: auth,
accept: 'application/vnd.github.VERSION.raw'
};
const fetchedDragonwellVersions = (
await this.http.getJson<IDragonwellAllVersions>(availableVersionsUrl)
await this.http.getJson<IDragonwellAllVersions>(
availableVersionsUrl,
headers
)
).result;
if (!fetchedDragonwellVersions) {