Skip to content

Commit

Permalink
feat: update logic of getting json file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Zosimov committed Sep 18, 2023
1 parent 3888c0a commit cf4e142
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
14 changes: 12 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
21 changes: 18 additions & 3 deletions src/distributions/dragonwell/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cf4e142

Please sign in to comment.