Fixing PR comments

This commit is contained in:
Shivam Gupta
2021-03-30 11:33:44 +05:30
parent c7ee2943a5
commit 3f7faa7e5e
2 changed files with 22 additions and 9 deletions

View File

@ -39,6 +39,8 @@ const core = __importStar(require("@actions/core"));
const graphql_1 = require("@octokit/graphql");
const helmToolName = 'helm';
const stableHelmVersion = 'v3.2.1';
const stableHelm3Version = 'v3.5.3';
const stableHelm2Version = 'v2.17.0';
const LATEST_HELM2_VERSION = '2.*';
const LATEST_HELM3_VERSION = '3.*';
function getExecutableExtension() {
@ -123,12 +125,16 @@ function getLatestHelmVersionFor(type) {
return latestValidRelease.tagName;
}
catch (err) {
core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), stableHelmVersion));
core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), getStableHelmVersionFor(type)));
return getStableHelmVersionFor(type);
}
core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, stableHelmVersion));
return stableHelmVersion;
core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, getStableHelmVersionFor(type)));
return getStableHelmVersionFor(type);
});
}
function getStableHelmVersionFor(type) {
return type === "v2" ? stableHelm2Version : stableHelm3Version;
}
// isValidVersion checks if verison matches the specified type and is a stable release
function isValidVersion(version, type) {
if (!version.toLocaleLowerCase().startsWith(type))
@ -172,4 +178,4 @@ function run() {
core.setOutput('helm-path', cachedPath);
});
}
run().catch(core.setFailed);
run().catch(core.setFailed);

View File

@ -12,6 +12,8 @@ import { graphql } from '@octokit/graphql';
const helmToolName = 'helm';
const stableHelmVersion = 'v3.2.1';
const stableHelm3Version = 'v3.5.3';
const stableHelm2Version = 'v2.17.0';
const LATEST_HELM2_VERSION = '2.*';
const LATEST_HELM3_VERSION = '3.*';
@ -78,7 +80,7 @@ async function downloadHelm(version: string): Promise<string> {
return helmpath;
}
async function getLatestHelmVersionFor(type) {
async function getLatestHelmVersionFor(type: string): Promise<string> {
const token = core.getInput('token', { 'required': true });
try {
const { repository } = await graphql(
@ -103,14 +105,19 @@ async function getLatestHelmVersionFor(type) {
if (latestValidRelease)
return latestValidRelease.tagName;
} catch (err) {
core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), stableHelmVersion));
core.warning(util.format("Error while fetching the latest Helm %s release. Error: %s. Using default Helm version %s.", type, err.toString(), getStableHelmVersionFor(type)));
return getStableHelmVersionFor(type);
}
core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, stableHelmVersion));
return stableHelmVersion;
core.warning(util.format("Could not find stable release for Helm %s. Using default Helm version %s.", type, getStableHelmVersionFor(type)));
return getStableHelmVersionFor(type);
}
function getStableHelmVersionFor(type: string) {
return type==="v2" ? stableHelm2Version : stableHelm3Version;
}
// isValidVersion checks if verison matches the specified type and is a stable release
function isValidVersion(version, type): boolean {
function isValidVersion(version: string, type: string): boolean {
if (!version.toLocaleLowerCase().startsWith(type))
return false;
return version.indexOf('rc') == -1