mirror of
				https://github.com/SamKirkland/FTP-Deploy-Action.git
				synced 2025-10-31 09:34:01 +00:00 
			
		
		
		
	v4.2.0 beta
- fixes for 550 folder issue - updated excludes option format
This commit is contained in:
		
							parent
							
								
									65c6a8f943
								
							
						
					
					
						commit
						ba86a1bf13
					
				
							
								
								
									
										64
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										64
									
								
								README.md
									
									
									
									
									
								
							| @ -23,7 +23,7 @@ jobs: | ||||
|       uses: actions/checkout@v2 | ||||
|      | ||||
|     - name: 📂 Sync files | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.1.0 | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.2.0 | ||||
|       with: | ||||
|         server: ftp.samkirkland.com | ||||
|         username: myFtpUserName | ||||
| @ -55,21 +55,21 @@ Keys can be added directly to your .yml config file or referenced from your proj | ||||
| To add a `secret` go to the `Settings` tab in your project then select `Secrets`. | ||||
| I strongly recommend you store your `password` as a secret. | ||||
| 
 | ||||
| | Key Name                | Required | Example                    | Default Value                                 | Description                                                                                                                                                        | | ||||
| |-------------------------|----------|----------------------------|-----------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||||
| | `server`                | Yes      | `ftp.samkirkland.com`      |                                               | Deployment destination server                                                                                                                                      | | ||||
| | `username`              | Yes      | `username@samkirkland.com` |                                               | FTP user name                                                                                                                                                      | | ||||
| | `password`              | Yes      | `CrazyUniquePassword&%123` |                                               | FTP password, be sure to escape quotes and spaces                                                                                                                  | | ||||
| | `port`                  | No       | `990`                      | `21`                                          | Server port to connect to (read your web hosts docs)                                                                                                               | | ||||
| | `protocol`              | No       | `ftps`                     | `ftp`                                         | `ftp`: provides no encryption, `ftps`: full encryption newest standard (aka "explicit" ftps), `ftps-legacy`: full encryption legacy standard (aka "implicit" ftps) | | ||||
| | `local-dir`             | No       | `./myFolderToPublish/`     | `./`                                          | Folder to upload from, must end with trailing slash `/`                                                                                                            | | ||||
| | `server-dir`            | No       | `public_html/www/`         | `./`                                          | Folder to upload to (on the server), must end with trailing slash `/`                                                                                              | | ||||
| | `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                                                                                 | | ||||
| | `exclude`               | No       |                            | `**/.git*` `**/.git*/**` `**/node_modules/**` | An array of glob patterns, these files will not be included in the publish/delete process. [List must be in yaml array format](#exclude-files). You can use [a glob tester](https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F.git%2A%2F%2A%2A&matches=false&tests=test%2Fsam&tests=.git%2F&tests=.github%2F&tests=.git%2Ftest&tests=.gitattributes&tests=.gitignore&tests=.git%2Fconfig&tests=.git%2Ftest%2Ftest&tests=.github%2Fworkflows%2Fmain.yml&tests=test%2F.git%2Fworkflows%2Fmain.yml&tests=node_modules%2Ffolder%2F&tests=node_modules%2Fotherfolder%2F&tests=subfolder%2Fnode_modules%2F) to test your pattern(s).                     | | ||||
| | `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           | | ||||
| | Key Name                | Required | Example                       | Default Value                 | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | | ||||
| |-------------------------|----------|-------------------------------|-------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||||
| | `server`                | Yes      | `ftp.samkirkland.com`         |                               | Deployment destination server                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ||||
| | `username`              | Yes      | `username@samkirkland.com`    |                               | FTP user name                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | | ||||
| | `password`              | Yes      | `CrazyUniquePassword&%123`    |                               | FTP password, be sure to escape quotes and spaces                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | | ||||
| | `port`                  | No       | `990`                         | `21`                          | Server port to connect to (read your web hosts docs)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | | ||||
| | `protocol`              | No       | `ftps`                        | `ftp`                         | `ftp`: provides no encryption, `ftps`: full encryption newest standard (aka "explicit" ftps), `ftps-legacy`: full encryption legacy standard (aka "implicit" ftps)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ||||
| | `local-dir`             | No       | `./myFolderToPublish/`        | `./`                          | Folder to upload from, must end with trailing slash `/`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | | ||||
| | `server-dir`            | No       | `public_html/www/`            | `./`                          | Folder to upload to (on the server), must end with trailing slash `/`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | | ||||
| | `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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | | ||||
| | `exclude`               | No       | [See Example](#exclude-files) | [See Example](#exclude-files) | An array of glob patterns, these files will not be included in the publish/delete process. [List MUST be in this format](#exclude-files). You can use [a glob tester](https://www.digitalocean.com/community/tools/glob?comments=true&glob=%2A%2A%2F.git%2A%2F%2A%2A&matches=false&tests=test%2Fsam&tests=.git%2F&tests=.github%2F&tests=.git%2Ftest&tests=.gitattributes&tests=.gitignore&tests=.git%2Fconfig&tests=.git%2Ftest%2Ftest&tests=.github%2Fworkflows%2Fmain.yml&tests=test%2F.git%2Fworkflows%2Fmain.yml&tests=node_modules%2Ffolder%2F&tests=node_modules%2Fotherfolder%2F&tests=subfolder%2Fnode_modules%2F) to test your pattern(s). | | ||||
| | `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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | | ||||
| 
 | ||||
| 
 | ||||
| # Common Examples | ||||
| @ -98,7 +98,7 @@ jobs: | ||||
|         npm run build | ||||
|      | ||||
|     - name: 📂 Sync files | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.1.0 | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.2.0 | ||||
|       with: | ||||
|         server: ftp.samkirkland.com | ||||
|         username: myFtpUserName | ||||
| @ -118,7 +118,7 @@ jobs: | ||||
|       uses: actions/checkout@v2 | ||||
| 
 | ||||
|     - name: 📂 Sync files | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.1.0 | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.2.0 | ||||
|       with: | ||||
|         server: ftp.samkirkland.com | ||||
|         username: myFtpUserName | ||||
| @ -127,7 +127,7 @@ jobs: | ||||
|         port: 1234 # todo replace with your web hosts ftps port | ||||
| ``` | ||||
| 
 | ||||
| #### Log only dry run: Use this mode for testing | ||||
| #### Log only dry run: Use this option for testing | ||||
| Ouputs a list of files that will be created/modified to sync your source without making any actual changes | ||||
| ```yml | ||||
| on: push | ||||
| @ -141,7 +141,7 @@ jobs: | ||||
|       uses: actions/checkout@v2 | ||||
| 
 | ||||
|     - name: 📂 Sync files | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.1.0 | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.2.0 | ||||
|       with: | ||||
|         server: ftp.samkirkland.com | ||||
|         username: myFtpUserName | ||||
| @ -163,18 +163,30 @@ jobs: | ||||
|       uses: actions/checkout@v2 | ||||
| 
 | ||||
|     - name: 📂 Sync files | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.1.0 | ||||
|       uses: SamKirkland/FTP-Deploy-Action@4.2.0 | ||||
|       with: | ||||
|         server: ftp.samkirkland.com | ||||
|         username: myFtpUserName | ||||
|         password: ${{ secrets.password }} | ||||
|         exclude: | ||||
|           - **/.git* | ||||
|           - **/.git*/** | ||||
|           - **/node_modules/** | ||||
|           - fileToExclude.txt | ||||
|         exclude: | | ||||
|           **/.git* | ||||
|           **/.git*/** | ||||
|           **/node_modules/** | ||||
|           fileToExclude.txt | ||||
| ``` | ||||
| 
 | ||||
| `exclude` has the following default value | ||||
| ```yml | ||||
| exclude: | | ||||
|   **/.git* | ||||
|   **/.git*/** | ||||
|   **/node_modules/** | ||||
| ``` | ||||
| if you overwrite the default value you will probably want to respecify them | ||||
| 
 | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
| _Want another example? Let me know by creating a [github issue](https://github.com/SamKirkland/FTP-Deploy-Action/issues/new)_ | ||||
| 
 | ||||
| --- | ||||
|  | ||||
							
								
								
									
										1469
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1469
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										15
									
								
								migration.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								migration.md
									
									
									
									
									
								
							| @ -1,3 +1,18 @@ | ||||
| # Migrating from v4.1.0 to v4.2.0 | ||||
| 
 | ||||
| `v4.2.0` parses the `exclude` option in a more standard way. | ||||
| 
 | ||||
| Going forward the `exclude` option **must** be in the following format | ||||
| ```yml | ||||
| exclude: | | ||||
|   **/.git* | ||||
|   **/.git*/** | ||||
|   **/node_modules/** | ||||
|   fileToExclude.txt | ||||
| ``` | ||||
| 
 | ||||
| --- | ||||
| 
 | ||||
| # Migrating from v3 to v4 | ||||
| 
 | ||||
| Migrating from v3 to v4 should be fairly straightforward. Version 4 was designed with speed and ease of initial setup in mind. Going forward version 4 will be the only supported version. | ||||
|  | ||||
							
								
								
									
										2925
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2925
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										20
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								package.json
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "ftp-deploy-action", | ||||
|   "version": "4.1.0", | ||||
|   "version": "4.2.0", | ||||
|   "private": true, | ||||
|   "description": "Automate deploying websites and more with this GitHub action", | ||||
|   "main": "dist/index.js", | ||||
| @ -22,20 +22,20 @@ | ||||
|   "author": "Sam Kirkland", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/core": "^1.4.0", | ||||
|     "@samkirkland/ftp-deploy": "^1.1.0", | ||||
|     "@types/jest": "^26.0.23", | ||||
|     "jest": "^27.0.5", | ||||
|     "ts-jest": "^27.0.3", | ||||
|     "ts-node-dev": "^1.1.6" | ||||
|     "@actions/core": "^1.6.0", | ||||
|     "@samkirkland/ftp-deploy": "^1.1.1", | ||||
|     "@types/jest": "^27.0.2", | ||||
|     "jest": "^27.2.5", | ||||
|     "ts-jest": "^27.0.5", | ||||
|     "ts-node-dev": "^1.1.8" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/node": "^14.0.27", | ||||
|     "@typescript-eslint/eslint-plugin": "^4.28.0", | ||||
|     "@typescript-eslint/parser": "^4.28.0", | ||||
|     "@vercel/ncc": "^0.28.6", | ||||
|     "@typescript-eslint/parser": "^4.33.0", | ||||
|     "@vercel/ncc": "^0.31.1", | ||||
|     "eslint": "^7.29.0", | ||||
|     "eslint-plugin-jest": "^24.3.6", | ||||
|     "typescript": "^4.3.4" | ||||
|     "typescript": "^4.4.3" | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| import { optionalBoolean, optionalInt, optionalLogLevel, optionalProtocol, optionalSecurity, optionalString, optionalStringArray } from "./parse"; | ||||
| import { optionalBoolean, optionalInt, optionalLogLevel, optionalProtocol, optionalSecurity, optionalString } from "./parse"; | ||||
| 
 | ||||
| describe("boolean", () => { | ||||
|     test("false", () => { | ||||
| @ -103,33 +103,3 @@ describe("security", () => { | ||||
|         expect(optionalSecurity("test", "strict")).toBe("strict"); | ||||
|     }); | ||||
| }); | ||||
| 
 | ||||
| describe("array", () => { | ||||
|     test("empty", () => { | ||||
|         expect(optionalStringArray("test", "")).toEqual(undefined); | ||||
|     }); | ||||
| 
 | ||||
|     test("empty array", () => { | ||||
|         expect(optionalStringArray("test", "[]")).toEqual([]); | ||||
|     }); | ||||
| 
 | ||||
|     test(`["test.txt"]`, () => { | ||||
|         expect(optionalStringArray("test", "[test.txt]")).toEqual(["test.txt"]); | ||||
|     }); | ||||
| 
 | ||||
|     test(`[ "test.txt" ]`, () => { | ||||
|         expect(optionalStringArray("test", "[ test.txt ]")).toEqual(["test.txt"]); | ||||
|     }); | ||||
| 
 | ||||
|     test(`["test.txt", "folder/**/*"]`, () => { | ||||
|         expect(optionalStringArray("test", "[test.txt, folder/**/*]")).toEqual(["test.txt", "folder/**/*"]); | ||||
|     }); | ||||
| 
 | ||||
|     test(`["test.txt", "folder/**/*", "*other"]`, () => { | ||||
|         expect(optionalStringArray("test", `test.txt\n  - folder/**/*\n  - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]); | ||||
|     }); | ||||
| 
 | ||||
|     test(`["test.txt", "folder/**/*", "*other"]`, () => { | ||||
|         expect(optionalStringArray("test", `\n  - test.txt\n  - folder/**/*\n  - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]); | ||||
|     }); | ||||
| }); | ||||
| @ -16,14 +16,14 @@ async function runDeployment() { | ||||
|       "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")), | ||||
|       "exclude": optionalStringArray("exclude", core.getMultilineInput("exclude")), | ||||
|       "log-level": optionalLogLevel("log-level", core.getInput("log-level")), | ||||
|       "security": optionalSecurity("security", core.getInput("security")) | ||||
|     }; | ||||
| 
 | ||||
|     await deploy(args); | ||||
|   } | ||||
|   catch (error) { | ||||
|   catch (error: any) { | ||||
|     core.setFailed(error); | ||||
|   } | ||||
| } | ||||
|  | ||||
							
								
								
									
										22
									
								
								src/parse.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/parse.ts
									
									
									
									
									
								
							| @ -90,24 +90,14 @@ export function optionalInt(argumentName: string, rawValue: string): number | un | ||||
|     throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`); | ||||
| } | ||||
| 
 | ||||
| export function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined { | ||||
| export function optionalStringArray(argumentName: string, rawValue: string[]): string[] | undefined { | ||||
|     if (typeof rawValue === "string") { | ||||
|         throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`); | ||||
|     } | ||||
| 
 | ||||
|     if (rawValue.length === 0) { | ||||
|         return undefined; | ||||
|     } | ||||
| 
 | ||||
|     const valueTrim = rawValue.trim(); | ||||
| 
 | ||||
|     if (valueTrim.startsWith("[")) { | ||||
|         // remove [ and ] - then convert to array
 | ||||
|         return rawValue.replace(/[\[\]]/g, "").trim().split(", ").filter(str => str !== ""); | ||||
|     } | ||||
| 
 | ||||
|     // split value by space and comma
 | ||||
|     const valueAsArrayDouble = rawValue.split(" - ").map(str => str.trim()).filter(str => str !== ""); | ||||
| 
 | ||||
|     if (valueAsArrayDouble.length) { | ||||
|         return valueAsArrayDouble; | ||||
|     } | ||||
| 
 | ||||
|     throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option excepts an array in the format [val1, val2] or val1\/n - val2`); | ||||
|     return rawValue; | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user