mirror of
https://github.com/actions/setup-java.git
synced 2024-11-14 14:08:05 +00:00
fix: fix review points
This commit is contained in:
parent
4f1c6f6018
commit
8afb584024
@ -4,12 +4,12 @@ import semver from 'semver';
|
|||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {OutgoingHttpHeaders} from 'http';
|
|
||||||
|
|
||||||
import {JavaBase} from '../base-installer';
|
import {JavaBase} from '../base-installer';
|
||||||
import {
|
import {
|
||||||
extractJdkFile,
|
extractJdkFile,
|
||||||
getDownloadArchiveExtension,
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders,
|
||||||
isVersionSatisfies
|
isVersionSatisfies
|
||||||
} from '../../util';
|
} from '../../util';
|
||||||
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
import {IDragonwellVersions, IDragonwellAllVersions} from './models';
|
||||||
@ -219,8 +219,6 @@ export class DragonwellDistribution extends JavaBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async fetchJsonFromBackupUrl(): Promise<IDragonwellAllVersions | null> {
|
private async fetchJsonFromBackupUrl(): Promise<IDragonwellAllVersions | null> {
|
||||||
const token = core.getInput('token');
|
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
|
||||||
const owner = 'dragonwell-releng';
|
const owner = 'dragonwell-releng';
|
||||||
const repository = 'dragonwell-setup-java';
|
const repository = 'dragonwell-setup-java';
|
||||||
const branch = 'main';
|
const branch = 'main';
|
||||||
@ -228,10 +226,7 @@ export class DragonwellDistribution extends JavaBase {
|
|||||||
|
|
||||||
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
const backupUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
|
|
||||||
const headers: OutgoingHttpHeaders = {
|
const headers = getGitHubHttpHeaders();
|
||||||
authorization: auth,
|
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
core.debug(
|
core.debug(
|
||||||
|
@ -4,10 +4,13 @@ import {
|
|||||||
JavaInstallerOptions,
|
JavaInstallerOptions,
|
||||||
JavaInstallerResults
|
JavaInstallerResults
|
||||||
} from '../base-models';
|
} from '../base-models';
|
||||||
import {extractJdkFile, getDownloadArchiveExtension} from '../../util';
|
import {
|
||||||
|
extractJdkFile,
|
||||||
|
getDownloadArchiveExtension,
|
||||||
|
getGitHubHttpHeaders
|
||||||
|
} from '../../util';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import {OutgoingHttpHeaders} from 'http';
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {ITypedResponse} from '@actions/http-client/interfaces';
|
import {ITypedResponse} from '@actions/http-client/interfaces';
|
||||||
@ -85,8 +88,6 @@ export class MicrosoftDistributions extends JavaBase {
|
|||||||
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
private async getAvailableVersions(): Promise<tc.IToolRelease[] | null> {
|
||||||
// TODO get these dynamically!
|
// TODO get these dynamically!
|
||||||
// We will need Microsoft to add an endpoint where we can query for versions.
|
// We will need Microsoft to add an endpoint where we can query for versions.
|
||||||
const token = core.getInput('token');
|
|
||||||
const auth = !token ? undefined : `token ${token}`;
|
|
||||||
const owner = 'actions';
|
const owner = 'actions';
|
||||||
const repository = 'setup-java';
|
const repository = 'setup-java';
|
||||||
const branch = 'main';
|
const branch = 'main';
|
||||||
@ -96,10 +97,7 @@ export class MicrosoftDistributions extends JavaBase {
|
|||||||
let releases: tc.IToolRelease[] | null = null;
|
let releases: tc.IToolRelease[] | null = null;
|
||||||
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
const fileUrl = `https://api.github.com/repos/${owner}/${repository}/contents/${filePath}?ref=${branch}`;
|
||||||
|
|
||||||
const headers: OutgoingHttpHeaders = {
|
const headers = getGitHubHttpHeaders();
|
||||||
authorization: auth,
|
|
||||||
accept: 'application/vnd.github.VERSION.raw'
|
|
||||||
};
|
|
||||||
|
|
||||||
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
let response: ITypedResponse<tc.IToolRelease[]> | null = null;
|
||||||
|
|
||||||
|
11
src/util.ts
11
src/util.ts
@ -7,6 +7,7 @@ import * as core from '@actions/core';
|
|||||||
|
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
import {INPUT_JOB_STATUS, DISTRIBUTIONS_ONLY_MAJOR_VERSION} from './constants';
|
||||||
|
import {OutgoingHttpHeaders} from 'http';
|
||||||
|
|
||||||
export function getTempDir() {
|
export function getTempDir() {
|
||||||
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
const tempDirectory = process.env['RUNNER_TEMP'] || os.tmpdir();
|
||||||
@ -161,3 +162,13 @@ export function convertVersionToSemver(version: number[] | string) {
|
|||||||
}
|
}
|
||||||
return mainVersion;
|
return mainVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGitHubHttpHeaders(): OutgoingHttpHeaders {
|
||||||
|
const token = core.getInput('token');
|
||||||
|
const auth = !token ? undefined : `token ${token}`;
|
||||||
|
const headers: OutgoingHttpHeaders = {
|
||||||
|
authorization: auth,
|
||||||
|
accept: 'application/vnd.github.VERSION.raw'
|
||||||
|
};
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user