hooked up additional props

added npm badges
Updated readme
This commit is contained in:
SamKirkland
2020-08-27 23:43:10 -05:00
parent 64fd8ab1ea
commit afd59edb41
6 changed files with 4717 additions and 4561 deletions

View File

@@ -1,4 +1,4 @@
import * as core from "@actions/core";
import core from "@actions/core";
import { deploy } from "@samkirkland/ftp-deploy";
import { IFtpDeployArguments } from "@samkirkland/ftp-deploy/dist/module/types";
@@ -7,16 +7,16 @@ async function runDeployment() {
server: core.getInput("server", { required: true }),
username: core.getInput("username", { required: true }),
password: core.getInput("password", { required: true }),
protocol: core.getInput("protocol") as any, // todo fix
port: core.getInput("port") as any, // todo fix
"local-dir": core.getInput("local-dir") as any, // todo fix
"server-dir": core.getInput("server-dir") as any, // todo fix
"state-name": core.getInput("state-name") as any, // todo fix
"dry-run": core.getInput("dry-run") as any, // todo fix
"dangerous-clean-slate": core.getInput("dangerous-clean-slate") as any, // todo fix
"include": core.getInput("include") as any, // todo fix
"exclude": core.getInput("exclude") as any, // todo fix
"log-level": core.getInput("log-level") as any // todo fix
protocol: optionalProtocol("protocol", core.getInput("protocol")),
port: optionalInt("port", core.getInput("port")),
"local-dir": core.getInput("local-dir"),
"server-dir": core.getInput("server-dir"),
"state-name": core.getInput("state-name"),
"dry-run": optionalBoolean("dry-run", core.getInput("dry-run")),
"dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")),
"include": optionalStringArray("include", core.getInput("include")),
"exclude": optionalStringArray("exclude", core.getInput("exclude")),
"log-level": optionalLogLevel("log-level", core.getInput("log-level"))
};
@@ -28,4 +28,90 @@ async function runDeployment() {
}
}
runDeployment();
runDeployment();
function optionalBoolean(argumentName: string, rawValue: string | undefined): boolean | undefined {
if (rawValue === undefined) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
if (cleanValue === "true") {
return true;
}
if (cleanValue === "false") {
return false;
}
core.setFailed(`${argumentName}: invalid parameter - please use a boolean, you provided "${rawValue}". Try true or false instead.`);
}
function optionalProtocol(argumentName: string, rawValue: string | undefined): "ftp" | "ftps" | "ftps-legacy" | undefined {
if (rawValue === undefined) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
if (cleanValue === "ftp") {
return "ftp";
}
if (cleanValue === "ftps") {
return "ftps";
}
if (cleanValue === "ftps-legacy") {
return "ftps-legacy";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`);
}
function optionalLogLevel(argumentName: string, rawValue: string | undefined): "warn" | "info" | "debug" | undefined {
if (rawValue === undefined) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
if (cleanValue === "warn") {
return "warn";
}
if (cleanValue === "info") {
return "info";
}
if (cleanValue === "debug") {
return "debug";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`);
}
function optionalInt(argumentName: string, rawValue: string | undefined): number | undefined {
if (rawValue === undefined) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
const valueAsNumber = parseFloat(cleanValue);
if (Number.isInteger(valueAsNumber)) {
return valueAsNumber;
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
}
function optionalStringArray(argumentName: string, rawValue: string | undefined): string[] | undefined {
if (rawValue === undefined) {
return undefined;
}
// split value by space and comma
return rawValue.split(", ");
}