mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2025-08-14 14:05:05 +00:00
updated ftp-deploy version
This commit is contained in:
parent
b6b6e42be5
commit
c14c34b02c
@ -1,3 +1,2 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
1
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -23,4 +23,5 @@ jobs:
|
||||
**My Action Log**
|
||||
```
|
||||
# Paste Log here
|
||||
# you may want enable verbose logging with log-level: verbose
|
||||
```
|
||||
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -92,7 +92,4 @@ typings/
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
lib/**/*
|
||||
Thumbs.db
|
25
README.md
25
README.md
@ -9,9 +9,6 @@ Automate deploying websites and more with this GitHub action
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
---
|
||||
|
||||
### 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 |
|
||||
| `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 |
|
||||
| `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 |
|
||||
| `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 |
|
||||
|
||||
|
||||
@ -190,17 +186,14 @@ jobs:
|
||||
```
|
||||
</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`
|
||||
- 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)
|
||||
|
||||
Example of `package.json`:
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"deploy": "ftp-deploy --server ftp.samkirkland.com --username test@samkirkland.com --password \"CrazyUniquePassword&%123\"",
|
||||
},
|
||||
}
|
||||
```
|
||||
|
11
action.yml
11
action.yml
@ -11,12 +11,12 @@ inputs:
|
||||
password:
|
||||
required: true
|
||||
description: 'ftp password'
|
||||
protocol:
|
||||
required: false
|
||||
description: 'protocol to deploy with - ftp, ftps, or ftps-legacy'
|
||||
port:
|
||||
required: false
|
||||
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:
|
||||
required: false
|
||||
description: 'Folder to upload from, must end with trailing slash /'
|
||||
@ -32,9 +32,6 @@ inputs:
|
||||
dangerous-clean-slate:
|
||||
required: false
|
||||
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:
|
||||
required: false
|
||||
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'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'dist/index.js'
|
||||
main: 'dist/main.js'
|
||||
branding:
|
||||
icon: 'upload-cloud'
|
||||
color: 'orange'
|
6675
dist/index.js
vendored
6675
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
128
dist/main.js
vendored
Normal file
128
dist/main.js
vendored
Normal 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
26
package-lock.json
generated
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "ftp-deploy-action",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.5.tgz",
|
||||
"integrity": "sha512-mwpoNjHSWWh0IiALdDEQi3tru124JKn0yVNziIBzTME8QRv7thwoghVuT1jBRjFvdtoHsqD58IRHy1nf86paRg=="
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
|
||||
"integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
|
||||
},
|
||||
"@babel/code-frame": {
|
||||
"version": "7.10.4",
|
||||
@ -147,9 +147,9 @@
|
||||
}
|
||||
},
|
||||
"@samkirkland/ftp-deploy": {
|
||||
"version": "0.9.6",
|
||||
"resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-0.9.6.tgz",
|
||||
"integrity": "sha512-6rUspSm4pSHUYRUwStvtAVIE7tkCvEs2bUcI9wtfN90COVdxUJ/hNwOF92jjhRqdp9287q+owVhbUpfJ29Twpg==",
|
||||
"version": "0.9.7",
|
||||
"resolved": "https://registry.npmjs.org/@samkirkland/ftp-deploy/-/ftp-deploy-0.9.7.tgz",
|
||||
"integrity": "sha512-4kdfy7tMCG4R+JGCK5zD3JwelL8au3Y1a3W5rBBgGRgPADBTCSS5hXDithKpKNO2ogMUBGxFfC9ebS/IkhPtqw==",
|
||||
"requires": {
|
||||
"basic-ftp": "^4.6.2",
|
||||
"lodash": "^4.17.20",
|
||||
@ -240,12 +240,6 @@
|
||||
"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": {
|
||||
"version": "7.4.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.0.tgz",
|
||||
@ -1384,9 +1378,9 @@
|
||||
"integrity": "sha512-s1Iam6Gwz3JI5Hweaz4GoCD1WUNUIyzePFy5+Js2hjwGVt2Z79wNN+ZKOZ2vB6C+Xs6njyB84Z1IthQg8d9LxA=="
|
||||
},
|
||||
"pretty-ms": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.0.tgz",
|
||||
"integrity": "sha512-J3aPWiC5e9ZeZFuSeBraGxSkGMOvulSWsxDByOcbD1Pr75YL3LSNIKIb52WXbCLE1sS5s4inBBbryjF4Y05Ceg==",
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-7.0.1.tgz",
|
||||
"integrity": "sha512-973driJZvxiGOQ5ONsFhOF/DtzPMOMtgC11kCpUrPGMTgqp2q/1gwzCquocrN33is0VZ5GFHXZYMM9l6h67v2Q==",
|
||||
"requires": {
|
||||
"parse-ms": "^2.1.0"
|
||||
}
|
||||
|
12
package.json
12
package.json
@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "ftp-deploy-action",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"description": "Automate deploying websites and more with this GitHub action",
|
||||
"main": "dist/main.js",
|
||||
"scripts": {
|
||||
"build": "ncc build src/main.ts --no-cache",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"all": "npm run build && npm run lint"
|
||||
"build": "tsc",
|
||||
"lint": "eslint src/**/*.ts"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -22,14 +21,13 @@
|
||||
"author": "Sam Kirkland",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.5",
|
||||
"@samkirkland/ftp-deploy": "^0.9.6",
|
||||
"@actions/core": "^1.2.6",
|
||||
"@samkirkland/ftp-deploy": "^0.9.7",
|
||||
"ts-node-dev": "^1.0.0-pre.62"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^14.0.27",
|
||||
"@typescript-eslint/parser": "^4.0.1",
|
||||
"@vercel/ncc": "^0.24.0",
|
||||
"eslint": "^7.8.1",
|
||||
"js-yaml": "^3.14.0",
|
||||
"typescript": "^4.0.2"
|
||||
|
19
src/main.ts
19
src/main.ts
@ -7,14 +7,13 @@ async function runDeployment() {
|
||||
server: core.getInput("server", { required: true }),
|
||||
username: core.getInput("username", { required: true }),
|
||||
password: core.getInput("password", { required: true }),
|
||||
protocol: optionalProtocol("protocol", core.getInput("protocol")),
|
||||
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")),
|
||||
"include": optionalStringArray("include", core.getInput("include")),
|
||||
"exclude": optionalStringArray("exclude", core.getInput("exclude")),
|
||||
"log-level": optionalLogLevel("log-level", core.getInput("log-level")),
|
||||
"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.`);
|
||||
}
|
||||
|
||||
function optionalLogLevel(argumentName: string, rawValue: string): "warn" | "info" | "debug" | undefined {
|
||||
function optionalLogLevel(argumentName: string, rawValue: string): "minimal" | "standard" | "verbose" | undefined {
|
||||
if (rawValue.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const cleanValue = rawValue.toLowerCase();
|
||||
if (cleanValue === "warn") {
|
||||
return "warn";
|
||||
if (cleanValue === "minimal") {
|
||||
return "minimal";
|
||||
}
|
||||
if (cleanValue === "info") {
|
||||
return "info";
|
||||
if (cleanValue === "standard") {
|
||||
return "standard";
|
||||
}
|
||||
if (cleanValue === "debug") {
|
||||
return "debug";
|
||||
if (cleanValue === "verbose") {
|
||||
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 {
|
||||
|
@ -1,8 +1,8 @@
|
||||
{
|
||||
"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'. */
|
||||
"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. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user