updated ftp-deploy version

This commit is contained in:
SamKirkland 2020-10-23 23:41:37 -05:00
parent b6b6e42be5
commit c14c34b02c
11 changed files with 169 additions and 6738 deletions

View File

@ -1,3 +1,2 @@
dist/ dist/
lib/
node_modules/ node_modules/

View File

@ -23,4 +23,5 @@ jobs:
**My Action Log** **My Action Log**
``` ```
# Paste Log here # Paste Log here
# you may want enable verbose logging with log-level: verbose
``` ```

5
.gitignore vendored
View File

@ -92,7 +92,4 @@ typings/
# OS metadata # OS metadata
.DS_Store .DS_Store
Thumbs.db Thumbs.db
# Ignore built ts files
lib/**/*

View File

@ -9,9 +9,6 @@ Automate deploying websites and more with this GitHub action
![FTP test](https://github.com/SamKirkland/FTP-Deploy-Action/workflows/FTP%20Test/badge.svg) ![FTP test](https://github.com/SamKirkland/FTP-Deploy-Action/workflows/FTP%20Test/badge.svg)
![FTPS test](https://github.com/SamKirkland/FTP-Deploy-Action/workflows/FTPS%20Test/badge.svg) ![FTPS test](https://github.com/SamKirkland/FTP-Deploy-Action/workflows/FTPS%20Test/badge.svg)
![npm](https://img.shields.io/npm/v/@samkirkland/ftp-deploy?style=flat-square)
![npm](https://img.shields.io/npm/dt/@samkirkland/ftp-deploy)
--- ---
### Usage Example ### Usage Example
@ -71,9 +68,8 @@ I strongly recommend you store your `password` as a secret.
| `state-name` | No | `folder/.sync-state.json` | `.ftp-deploy-sync-state.json` | Path and name of the state file - this file is used to track which files have been deployed | | `state-name` | No | `folder/.sync-state.json` | `.ftp-deploy-sync-state.json` | Path and name of the state file - this file is used to track which files have been deployed |
| `dry-run` | No | `true` | `false` | Prints which modifications will be made with current config options, but doesn't actually make any changes | | `dry-run` | No | `true` | `false` | Prints which modifications will be made with current config options, but doesn't actually make any changes |
| `dangerous-clean-slate` | No | `true` | `false` | Deletes ALL contents of server-dir, even items in excluded with 'exclude' argument | | `dangerous-clean-slate` | No | `true` | `false` | Deletes ALL contents of server-dir, even items in excluded with 'exclude' argument |
| `include` | No | | `` | :warning: not implemented yet - An array of glob patterns, these files will always be included in the publish/delete process - even if no change occurred |
| `exclude` | No | | `.git*` `.git*/**` `node_modules/**` `node_modules/**/*` | An array of glob patterns, these files will not be included in the publish/delete process | | `exclude` | No | | `.git*` `.git*/**` `node_modules/**` `node_modules/**/*` | An array of glob patterns, these files will not be included in the publish/delete process |
| `log-level` | No | `info` | `info` | `warn`: only important/warning info, `info`: default, log important/warning info & progress info, `debug`: log everything for debugging | | `log-level` | No | `minimal` | `standard` | `minimal`: only important info, `standard`: important info and basic file changes, `verbose`: print everything the script is doing |
| `security` | No | `strict` | `loose` | `strict`: Reject any connection which is not authorized with the list of supplied CAs. `loose`: Allow connection even when the domain is not certificate | | `security` | No | `strict` | `loose` | `strict`: Reject any connection which is not authorized with the list of supplied CAs. `loose`: Allow connection even when the domain is not certificate |
@ -190,17 +186,14 @@ jobs:
``` ```
</details> </details>
## Debugging your config locally
This action is a basic wrapper around my `@samkirkland/ftp-deploy` npm package. To test your config you can install [@samkirkland/ftp-deploy](https://github.com/SamKirkland/ftp-deploy) and then convert your config to a yml action. Settings are one-to-one, this action is only a wrapper.
## Debugging locally
## Contributing to this project
To run this code locally you will need to setup docker and act to run a environment similar to the one github uses for actions.
- Download/install docker for windows, make sure it is running
- `choco install act-cli` install [act](https://github.com/nektos/act)
- Install the npm package using `npm install --dev-only @samkirkland/ftp-deploy` - Install the npm package using `npm install --dev-only @samkirkland/ftp-deploy`
- Add a new key to your `package.json` file under `scripts` - Update the `deploy` script in `package.json` with a actual server/username/password
- You can run the script using the following command `npm run deploy` (run this in the folder that has the `package.json` file) - You can run the script using the following command `npm run deploy` (run this in the folder that has the `package.json` file)
Example of `package.json`:
```json
{
"scripts": {
"deploy": "ftp-deploy --server ftp.samkirkland.com --username test@samkirkland.com --password \"CrazyUniquePassword&%123\"",
},
}
```

View File

@ -11,12 +11,12 @@ inputs:
password: password:
required: true required: true
description: 'ftp password' description: 'ftp password'
protocol:
required: false
description: 'protocol to deploy with - ftp, ftps, or ftps-legacy'
port: port:
required: false required: false
description: 'Server port to connect to (read your web hosts docs)' description: 'Server port to connect to (read your web hosts docs)'
protocol:
required: false
description: 'protocol to deploy with - ftp, ftps, or ftps-legacy'
local-dir: local-dir:
required: false required: false
description: 'Folder to upload from, must end with trailing slash /' description: 'Folder to upload from, must end with trailing slash /'
@ -32,9 +32,6 @@ inputs:
dangerous-clean-slate: dangerous-clean-slate:
required: false required: false
description: 'Deletes ALL contents of server-dir, even items in excluded with exclude argument' description: 'Deletes ALL contents of server-dir, even items in excluded with exclude argument'
include:
required: false
description: 'An array of glob patterns, these files will always be included in the publish/delete process - even if no change occurred'
exclude: exclude:
required: false required: false
description: 'An array of glob patterns, these files will not be included in the publish/delete process' description: 'An array of glob patterns, these files will not be included in the publish/delete process'
@ -46,7 +43,7 @@ inputs:
description: 'strict or loose' description: 'strict or loose'
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/main.js'
branding: branding:
icon: 'upload-cloud' icon: 'upload-cloud'
color: 'orange' color: 'orange'

6675
dist/index.js vendored

File diff suppressed because it is too large Load Diff

128
dist/main.js vendored Normal file
View File

@ -0,0 +1,128 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const ftp_deploy_1 = require("@samkirkland/ftp-deploy");
async function runDeployment() {
const args = {
server: core.getInput("server", { required: true }),
username: core.getInput("username", { required: true }),
password: core.getInput("password", { required: true }),
port: optionalInt("port", core.getInput("port")),
protocol: optionalProtocol("protocol", core.getInput("protocol")),
"local-dir": optionalString(core.getInput("local-dir")),
"server-dir": optionalString(core.getInput("server-dir")),
"state-name": optionalString(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")),
"exclude": optionalStringArray("exclude", core.getInput("exclude")),
"log-level": optionalLogLevel("log-level", core.getInput("log-level")),
"security": optionalSecurity("security", core.getInput("security"))
};
try {
await ftp_deploy_1.deploy(args);
}
catch (error) {
core.setFailed(error);
}
}
runDeployment();
function optionalString(rawValue) {
if (rawValue.length === 0) {
return undefined;
}
return rawValue;
}
function optionalBoolean(argumentName, rawValue) {
if (rawValue.length === 0) {
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, rawValue) {
if (rawValue.length === 0) {
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, rawValue) {
if (rawValue.length === 0) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
if (cleanValue === "minimal") {
return "minimal";
}
if (cleanValue === "standard") {
return "standard";
}
if (cleanValue === "verbose") {
return "verbose";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "minimal", "standard", or "verbose" instead.`);
}
function optionalSecurity(argumentName, rawValue) {
if (rawValue.length === 0) {
return undefined;
}
const cleanValue = rawValue.toLowerCase();
if (cleanValue === "loose") {
return "loose";
}
if (cleanValue === "strict") {
return "strict";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "loose" or "strict" instead.`);
}
function optionalInt(argumentName, rawValue) {
if (rawValue.length === 0) {
return undefined;
}
const valueAsNumber = parseFloat(rawValue);
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, rawValue) {
if (rawValue.length === 0) {
return undefined;
}
// split value by space and comma
return rawValue.split(", ");
}

26
package-lock.json generated
View File

@ -1,13 +1,13 @@
{ {
"name": "ftp-deploy-action", "name": "ftp-deploy-action",
"version": "1.0.0", "version": "1.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.2.5", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.5.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
"integrity": "sha512-mwpoNjHSWWh0IiALdDEQi3tru124JKn0yVNziIBzTME8QRv7thwoghVuT1jBRjFvdtoHsqD58IRHy1nf86paRg==" "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
}, },
"@babel/code-frame": { "@babel/code-frame": {
"version": "7.10.4", "version": "7.10.4",
@ -147,9 +147,9 @@
} }
}, },
"@samkirkland/ftp-deploy": { "@samkirkland/ftp-deploy": {
"version": "0.9.6", "version": "0.9.7",
"resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-0.9.6.tgz", "resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-0.9.7.tgz",
"integrity": "sha512-6rUspSm4pSHUYRUwStvtAVIE7tkCvEs2bUcI9wtfN90COVdxUJ/hNwOF92jjhRqdp9287q+owVhbUpfJ29Twpg==", "integrity": "sha512-4kdfy7tMCG4R+JGCK5zD3JwelL8au3Y1a3W5rBBgGRgPADBTCSS5hXDithKpKNO2ogMUBGxFfC9ebS/IkhPtqw==",
"requires": { "requires": {
"basic-ftp": "^4.6.2", "basic-ftp": "^4.6.2",
"lodash": "^4.17.20", "lodash": "^4.17.20",
@ -240,12 +240,6 @@
"eslint-visitor-keys": "^2.0.0" "eslint-visitor-keys": "^2.0.0"
} }
}, },
"@vercel/ncc": {
"version": "0.24.0",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.24.0.tgz",
"integrity": "sha512-crqItMcIwCkvdXY/V3/TzrHJQx6nbIaRqE1cOopJhgGX6izvNov40SmD//nS5flfEvdK54YGjwVVq+zG6crjOg==",
"dev": true
},
"acorn": { "acorn": {
"version": "7.4.0", "version": "7.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
@ -1384,9 +1378,9 @@
"integrity": "sha512-s1Iam6Gwz3JI5Hweaz4GoCD1WUNUIyzePFy5+Js2hjwGVt2Z79wNN+ZKOZ2vB6C+Xs6njyB84Z1IthQg8d9LxA==" "integrity": "sha512-s1Iam6Gwz3JI5Hweaz4GoCD1WUNUIyzePFy5+Js2hjwGVt2Z79wNN+ZKOZ2vB6C+Xs6njyB84Z1IthQg8d9LxA=="
}, },
"pretty-ms": { "pretty-ms": {
"version": "7.0.0", "version": "7.0.1",
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.0.tgz", "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz",
"integrity": "sha512-J3aPWiC5e9ZeZFuSeBraGxSkGMOvulSWsxDByOcbD1Pr75YL3LSNIKIb52WXbCLE1sS5s4inBBbryjF4Y05Ceg==", "integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==",
"requires": { "requires": {
"parse-ms": "^2.1.0" "parse-ms": "^2.1.0"
} }

View File

@ -1,13 +1,12 @@
{ {
"name": "ftp-deploy-action", "name": "ftp-deploy-action",
"version": "1.0.0", "version": "1.0.1",
"private": true, "private": true,
"description": "Automate deploying websites and more with this GitHub action", "description": "Automate deploying websites and more with this GitHub action",
"main": "dist/main.js", "main": "dist/main.js",
"scripts": { "scripts": {
"build": "ncc build src/main.ts --no-cache", "build": "tsc",
"lint": "eslint src/**/*.ts", "lint": "eslint src/**/*.ts"
"all": "npm run build && npm run lint"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -22,14 +21,13 @@
"author": "Sam Kirkland", "author": "Sam Kirkland",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.5", "@actions/core": "^1.2.6",
"@samkirkland/ftp-deploy": "^0.9.6", "@samkirkland/ftp-deploy": "^0.9.7",
"ts-node-dev": "^1.0.0-pre.62" "ts-node-dev": "^1.0.0-pre.62"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^14.0.27", "@types/node": "^14.0.27",
"@typescript-eslint/parser": "^4.0.1", "@typescript-eslint/parser": "^4.0.1",
"@vercel/ncc": "^0.24.0",
"eslint": "^7.8.1", "eslint": "^7.8.1",
"js-yaml": "^3.14.0", "js-yaml": "^3.14.0",
"typescript": "^4.0.2" "typescript": "^4.0.2"

View File

@ -7,14 +7,13 @@ async function runDeployment() {
server: core.getInput("server", { required: true }), server: core.getInput("server", { required: true }),
username: core.getInput("username", { required: true }), username: core.getInput("username", { required: true }),
password: core.getInput("password", { required: true }), password: core.getInput("password", { required: true }),
protocol: optionalProtocol("protocol", core.getInput("protocol")),
port: optionalInt("port", core.getInput("port")), port: optionalInt("port", core.getInput("port")),
protocol: optionalProtocol("protocol", core.getInput("protocol")),
"local-dir": optionalString(core.getInput("local-dir")), "local-dir": optionalString(core.getInput("local-dir")),
"server-dir": optionalString(core.getInput("server-dir")), "server-dir": optionalString(core.getInput("server-dir")),
"state-name": optionalString(core.getInput("state-name")), "state-name": optionalString(core.getInput("state-name")),
"dry-run": optionalBoolean("dry-run", core.getInput("dry-run")), "dry-run": optionalBoolean("dry-run", core.getInput("dry-run")),
"dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")), "dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")),
"include": optionalStringArray("include", core.getInput("include")),
"exclude": optionalStringArray("exclude", core.getInput("exclude")), "exclude": optionalStringArray("exclude", core.getInput("exclude")),
"log-level": optionalLogLevel("log-level", core.getInput("log-level")), "log-level": optionalLogLevel("log-level", core.getInput("log-level")),
"security": optionalSecurity("security", core.getInput("security")) "security": optionalSecurity("security", core.getInput("security"))
@ -80,23 +79,23 @@ function optionalProtocol(argumentName: string, rawValue: string): "ftp" | "ftps
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`);
} }
function optionalLogLevel(argumentName: string, rawValue: string): "warn" | "info" | "debug" | undefined { function optionalLogLevel(argumentName: string, rawValue: string): "minimal" | "standard" | "verbose" | undefined {
if (rawValue.length === 0) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
if (cleanValue === "warn") { if (cleanValue === "minimal") {
return "warn"; return "minimal";
} }
if (cleanValue === "info") { if (cleanValue === "standard") {
return "info"; return "standard";
} }
if (cleanValue === "debug") { if (cleanValue === "verbose") {
return "debug"; return "verbose";
} }
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "minimal", "standard", or "verbose" instead.`);
} }
function optionalSecurity(argumentName: string, rawValue: string): "loose" | "strict" | undefined { function optionalSecurity(argumentName: string, rawValue: string): "loose" | "strict" | undefined {

View File

@ -1,8 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"outDir": "./lib", /* Redirect output structure to the directory. */ "outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"strict": true, /* Enable all strict type-checking options. */ "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */