mirror of
				https://github.com/SamKirkland/FTP-Deploy-Action.git
				synced 2025-10-31 16:03:58 +00:00 
			
		
		
		
	Closes #60
Due to node issue using exit code 0 for exceptions thrown in async methods. Fixed by moving getUserArguments inside try block.
This commit is contained in:
		
							parent
							
								
									c42c8e46fb
								
							
						
					
					
						commit
						a54cf4c5e3
					
				| @ -232,7 +232,7 @@ Similar in name to FTP but this protocol is entirely new and requires SSH access | ||||
| - Most web hosts change the default port (21), check with your host for your port number | ||||
| 
 | ||||
| 
 | ||||
| ##### [Setting up `known-hosts` allows you to remove the `--insecure` argument.](#known-hosts-setup) | ||||
| ### Known Hosts Setup | ||||
| **Windows**   | ||||
| In powershell run `ssh-keyscan -p <sshport> <hostname>` and copy the hash output   | ||||
| Example for samkirkland.com `ssh-keyscan -p 7822 samkirkland.com`   | ||||
| @ -384,13 +384,13 @@ jobs: | ||||
| <details id="cant-access-remote-sftp"> | ||||
|   <summary>Can't access remote 'sftp://', exiting...</summary> | ||||
|    | ||||
|   See **"Failed to upload files"** section above | ||||
|   See ["Failed to upload files"](#failed-to-upload) section above | ||||
| </details> | ||||
| 
 | ||||
| <details id="cant-access-remote-ftps"> | ||||
|   <summary>Can't access remote 'ftps://', exiting...</summary> | ||||
|    | ||||
|   See **"Failed to upload files"** section above | ||||
|   See ["Failed to upload files"](#failed-to-upload) section above | ||||
| </details> | ||||
| 
 | ||||
| <details id="files-arent_uploading"> | ||||
|  | ||||
							
								
								
									
										668
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										668
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -43,7 +43,7 @@ module.exports = | ||||
| /************************************************************************/ | ||||
| /******/ ({ | ||||
| 
 | ||||
| /***/ 9: | ||||
| /***/ 1: | ||||
| /***/ (function(__unusedmodule, exports, __webpack_require__) { | ||||
| 
 | ||||
| "use strict"; | ||||
| @ -58,9 +58,316 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | ||||
|     }); | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const os = __webpack_require__(87); | ||||
| const events = __webpack_require__(614); | ||||
| const child = __webpack_require__(129); | ||||
| const childProcess = __webpack_require__(129); | ||||
| const path = __webpack_require__(622); | ||||
| const util_1 = __webpack_require__(669); | ||||
| const ioUtil = __webpack_require__(672); | ||||
| const exec = util_1.promisify(childProcess.exec); | ||||
| /** | ||||
|  * Copies a file or folder. | ||||
|  * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js
 | ||||
|  * | ||||
|  * @param     source    source path | ||||
|  * @param     dest      destination path | ||||
|  * @param     options   optional. See CopyOptions. | ||||
|  */ | ||||
| function cp(source, dest, options = {}) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const { force, recursive } = readCopyOptions(options); | ||||
|         const destStat = (yield ioUtil.exists(dest)) ? yield ioUtil.stat(dest) : null; | ||||
|         // Dest is an existing file, but not forcing
 | ||||
|         if (destStat && destStat.isFile() && !force) { | ||||
|             return; | ||||
|         } | ||||
|         // If dest is an existing directory, should copy inside.
 | ||||
|         const newDest = destStat && destStat.isDirectory() | ||||
|             ? path.join(dest, path.basename(source)) | ||||
|             : dest; | ||||
|         if (!(yield ioUtil.exists(source))) { | ||||
|             throw new Error(`no such file or directory: ${source}`); | ||||
|         } | ||||
|         const sourceStat = yield ioUtil.stat(source); | ||||
|         if (sourceStat.isDirectory()) { | ||||
|             if (!recursive) { | ||||
|                 throw new Error(`Failed to copy. ${source} is a directory, but tried to copy without recursive flag.`); | ||||
|             } | ||||
|             else { | ||||
|                 yield cpDirRecursive(source, newDest, 0, force); | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             if (path.relative(source, newDest) === '') { | ||||
|                 // a file cannot be copied to itself
 | ||||
|                 throw new Error(`'${newDest}' and '${source}' are the same file`); | ||||
|             } | ||||
|             yield copyFile(source, newDest, force); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| exports.cp = cp; | ||||
| /** | ||||
|  * Moves a path. | ||||
|  * | ||||
|  * @param     source    source path | ||||
|  * @param     dest      destination path | ||||
|  * @param     options   optional. See MoveOptions. | ||||
|  */ | ||||
| function mv(source, dest, options = {}) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (yield ioUtil.exists(dest)) { | ||||
|             let destExists = true; | ||||
|             if (yield ioUtil.isDirectory(dest)) { | ||||
|                 // If dest is directory copy src into dest
 | ||||
|                 dest = path.join(dest, path.basename(source)); | ||||
|                 destExists = yield ioUtil.exists(dest); | ||||
|             } | ||||
|             if (destExists) { | ||||
|                 if (options.force == null || options.force) { | ||||
|                     yield rmRF(dest); | ||||
|                 } | ||||
|                 else { | ||||
|                     throw new Error('Destination already exists'); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         yield mkdirP(path.dirname(dest)); | ||||
|         yield ioUtil.rename(source, dest); | ||||
|     }); | ||||
| } | ||||
| exports.mv = mv; | ||||
| /** | ||||
|  * Remove a path recursively with force | ||||
|  * | ||||
|  * @param inputPath path to remove | ||||
|  */ | ||||
| function rmRF(inputPath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (ioUtil.IS_WINDOWS) { | ||||
|             // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
 | ||||
|             // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
 | ||||
|             try { | ||||
|                 if (yield ioUtil.isDirectory(inputPath, true)) { | ||||
|                     yield exec(`rd /s /q "${inputPath}"`); | ||||
|                 } | ||||
|                 else { | ||||
|                     yield exec(`del /f /a "${inputPath}"`); | ||||
|                 } | ||||
|             } | ||||
|             catch (err) { | ||||
|                 // if you try to delete a file that doesn't exist, desired result is achieved
 | ||||
|                 // other errors are valid
 | ||||
|                 if (err.code !== 'ENOENT') | ||||
|                     throw err; | ||||
|             } | ||||
|             // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
 | ||||
|             try { | ||||
|                 yield ioUtil.unlink(inputPath); | ||||
|             } | ||||
|             catch (err) { | ||||
|                 // if you try to delete a file that doesn't exist, desired result is achieved
 | ||||
|                 // other errors are valid
 | ||||
|                 if (err.code !== 'ENOENT') | ||||
|                     throw err; | ||||
|             } | ||||
|         } | ||||
|         else { | ||||
|             let isDir = false; | ||||
|             try { | ||||
|                 isDir = yield ioUtil.isDirectory(inputPath); | ||||
|             } | ||||
|             catch (err) { | ||||
|                 // if you try to delete a file that doesn't exist, desired result is achieved
 | ||||
|                 // other errors are valid
 | ||||
|                 if (err.code !== 'ENOENT') | ||||
|                     throw err; | ||||
|                 return; | ||||
|             } | ||||
|             if (isDir) { | ||||
|                 yield exec(`rm -rf "${inputPath}"`); | ||||
|             } | ||||
|             else { | ||||
|                 yield ioUtil.unlink(inputPath); | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| exports.rmRF = rmRF; | ||||
| /** | ||||
|  * Make a directory.  Creates the full path with folders in between | ||||
|  * Will throw if it fails | ||||
|  * | ||||
|  * @param   fsPath        path to create | ||||
|  * @returns Promise<void> | ||||
|  */ | ||||
| function mkdirP(fsPath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         yield ioUtil.mkdirP(fsPath); | ||||
|     }); | ||||
| } | ||||
| exports.mkdirP = mkdirP; | ||||
| /** | ||||
|  * Returns path of a tool had the tool actually been invoked.  Resolves via paths. | ||||
|  * If you check and the tool does not exist, it will throw. | ||||
|  * | ||||
|  * @param     tool              name of the tool | ||||
|  * @param     check             whether to check if tool exists | ||||
|  * @returns   Promise<string>   path to tool | ||||
|  */ | ||||
| function which(tool, check) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if (!tool) { | ||||
|             throw new Error("parameter 'tool' is required"); | ||||
|         } | ||||
|         // recursive when check=true
 | ||||
|         if (check) { | ||||
|             const result = yield which(tool, false); | ||||
|             if (!result) { | ||||
|                 if (ioUtil.IS_WINDOWS) { | ||||
|                     throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`); | ||||
|                 } | ||||
|                 else { | ||||
|                     throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         try { | ||||
|             // build the list of extensions to try
 | ||||
|             const extensions = []; | ||||
|             if (ioUtil.IS_WINDOWS && process.env.PATHEXT) { | ||||
|                 for (const extension of process.env.PATHEXT.split(path.delimiter)) { | ||||
|                     if (extension) { | ||||
|                         extensions.push(extension); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             // if it's rooted, return it if exists. otherwise return empty.
 | ||||
|             if (ioUtil.isRooted(tool)) { | ||||
|                 const filePath = yield ioUtil.tryGetExecutablePath(tool, extensions); | ||||
|                 if (filePath) { | ||||
|                     return filePath; | ||||
|                 } | ||||
|                 return ''; | ||||
|             } | ||||
|             // if any path separators, return empty
 | ||||
|             if (tool.includes('/') || (ioUtil.IS_WINDOWS && tool.includes('\\'))) { | ||||
|                 return ''; | ||||
|             } | ||||
|             // build the list of directories
 | ||||
|             //
 | ||||
|             // Note, technically "where" checks the current directory on Windows. From a toolkit perspective,
 | ||||
|             // it feels like we should not do this. Checking the current directory seems like more of a use
 | ||||
|             // case of a shell, and the which() function exposed by the toolkit should strive for consistency
 | ||||
|             // across platforms.
 | ||||
|             const directories = []; | ||||
|             if (process.env.PATH) { | ||||
|                 for (const p of process.env.PATH.split(path.delimiter)) { | ||||
|                     if (p) { | ||||
|                         directories.push(p); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|             // return the first match
 | ||||
|             for (const directory of directories) { | ||||
|                 const filePath = yield ioUtil.tryGetExecutablePath(directory + path.sep + tool, extensions); | ||||
|                 if (filePath) { | ||||
|                     return filePath; | ||||
|                 } | ||||
|             } | ||||
|             return ''; | ||||
|         } | ||||
|         catch (err) { | ||||
|             throw new Error(`which failed with message ${err.message}`); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| exports.which = which; | ||||
| function readCopyOptions(options) { | ||||
|     const force = options.force == null ? true : options.force; | ||||
|     const recursive = Boolean(options.recursive); | ||||
|     return { force, recursive }; | ||||
| } | ||||
| function cpDirRecursive(sourceDir, destDir, currentDepth, force) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         // Ensure there is not a run away recursive copy
 | ||||
|         if (currentDepth >= 255) | ||||
|             return; | ||||
|         currentDepth++; | ||||
|         yield mkdirP(destDir); | ||||
|         const files = yield ioUtil.readdir(sourceDir); | ||||
|         for (const fileName of files) { | ||||
|             const srcFile = `${sourceDir}/${fileName}`; | ||||
|             const destFile = `${destDir}/${fileName}`; | ||||
|             const srcFileStat = yield ioUtil.lstat(srcFile); | ||||
|             if (srcFileStat.isDirectory()) { | ||||
|                 // Recurse
 | ||||
|                 yield cpDirRecursive(srcFile, destFile, currentDepth, force); | ||||
|             } | ||||
|             else { | ||||
|                 yield copyFile(srcFile, destFile, force); | ||||
|             } | ||||
|         } | ||||
|         // Change the mode for the newly created directory
 | ||||
|         yield ioUtil.chmod(destDir, (yield ioUtil.stat(sourceDir)).mode); | ||||
|     }); | ||||
| } | ||||
| // Buffered file copy
 | ||||
| function copyFile(srcFile, destFile, force) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         if ((yield ioUtil.lstat(srcFile)).isSymbolicLink()) { | ||||
|             // unlink/re-link it
 | ||||
|             try { | ||||
|                 yield ioUtil.lstat(destFile); | ||||
|                 yield ioUtil.unlink(destFile); | ||||
|             } | ||||
|             catch (e) { | ||||
|                 // Try to override file permission
 | ||||
|                 if (e.code === 'EPERM') { | ||||
|                     yield ioUtil.chmod(destFile, '0666'); | ||||
|                     yield ioUtil.unlink(destFile); | ||||
|                 } | ||||
|                 // other errors = it doesn't exist, no work to do
 | ||||
|             } | ||||
|             // Copy over symlink
 | ||||
|             const symlinkFull = yield ioUtil.readlink(srcFile); | ||||
|             yield ioUtil.symlink(symlinkFull, destFile, ioUtil.IS_WINDOWS ? 'junction' : null); | ||||
|         } | ||||
|         else if (!(yield ioUtil.exists(destFile)) || force) { | ||||
|             yield ioUtil.copyFile(srcFile, destFile); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| //# sourceMappingURL=io.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ 9: | ||||
| /***/ (function(__unusedmodule, exports, __webpack_require__) { | ||||
| 
 | ||||
| "use strict"; | ||||
| 
 | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     if (mod && mod.__esModule) return mod; | ||||
|     var result = {}; | ||||
|     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||||
|     result["default"] = mod; | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const os = __importStar(__webpack_require__(87)); | ||||
| const events = __importStar(__webpack_require__(614)); | ||||
| const child = __importStar(__webpack_require__(129)); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| const io = __importStar(__webpack_require__(1)); | ||||
| const ioUtil = __importStar(__webpack_require__(672)); | ||||
| /* eslint-disable @typescript-eslint/unbound-method */ | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| /* | ||||
| @ -406,6 +713,16 @@ class ToolRunner extends events.EventEmitter { | ||||
|      */ | ||||
|     exec() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             // root the tool path if it is unrooted and contains relative pathing
 | ||||
|             if (!ioUtil.isRooted(this.toolPath) && | ||||
|                 (this.toolPath.includes('/') || | ||||
|                     (IS_WINDOWS && this.toolPath.includes('\\')))) { | ||||
|                 // prefer options.cwd if it is specified, however options.cwd may also need to be rooted
 | ||||
|                 this.toolPath = path.resolve(process.cwd(), this.options.cwd || process.cwd(), this.toolPath); | ||||
|             } | ||||
|             // if the tool is only a file name, then resolve it from the PATH
 | ||||
|             // otherwise verify it exists (add extension on Windows if necessary)
 | ||||
|             this.toolPath = yield io.which(this.toolPath, true); | ||||
|             return new Promise((resolve, reject) => { | ||||
|                 this._debug(`exec tool: ${this.toolPath}`); | ||||
|                 this._debug('arguments:'); | ||||
| @ -494,6 +811,12 @@ class ToolRunner extends events.EventEmitter { | ||||
|                         resolve(exitCode); | ||||
|                     } | ||||
|                 }); | ||||
|                 if (this.options.input) { | ||||
|                     if (!cp.stdin) { | ||||
|                         throw new Error('child process missing stdin'); | ||||
|                     } | ||||
|                     cp.stdin.end(this.options.input); | ||||
|                 } | ||||
|             }); | ||||
|         }); | ||||
|     } | ||||
| @ -668,16 +991,17 @@ const exec = __importStar(__webpack_require__(986)); | ||||
| const fs_1 = __importDefault(__webpack_require__(747)); | ||||
| const util_1 = __webpack_require__(669); | ||||
| const writeFileAsync = util_1.promisify(fs_1.default.writeFile); | ||||
| const errorDeploying = "⚠️ Error deploying"; | ||||
| function run() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const userArguments = getUserArguments(); | ||||
|         try { | ||||
|             const userArguments = getUserArguments(); | ||||
|             yield configureHost(userArguments); | ||||
|             yield syncFiles(userArguments); | ||||
|             console.log("✅ Deploy Complete"); | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error("⚠️ Error deploying"); | ||||
|             console.error(errorDeploying); | ||||
|             core.setFailed(error.message); | ||||
|         } | ||||
|     }); | ||||
| @ -698,7 +1022,7 @@ function configureHost(args) { | ||||
|         } | ||||
|         catch (error) { | ||||
|             console.error("⚠️ Error configuring known_hosts"); | ||||
|             throw error; | ||||
|             core.setFailed(error.message); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| @ -731,12 +1055,18 @@ function syncFiles(args) { | ||||
|         catch (error) { | ||||
|             console.error("⚠️ Failed to upload files"); | ||||
|             core.setFailed(error.message); | ||||
|             throw error; | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ 357: | ||||
| /***/ (function(module) { | ||||
| 
 | ||||
| module.exports = require("assert"); | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ 431: | ||||
| @ -744,17 +1074,24 @@ function syncFiles(args) { | ||||
| 
 | ||||
| "use strict"; | ||||
| 
 | ||||
| var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     if (mod && mod.__esModule) return mod; | ||||
|     var result = {}; | ||||
|     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||||
|     result["default"] = mod; | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const os = __webpack_require__(87); | ||||
| const os = __importStar(__webpack_require__(87)); | ||||
| /** | ||||
|  * Commands | ||||
|  * | ||||
|  * Command Format: | ||||
|  *   ##[name key=value;key=value]message | ||||
|  *   ::name key=value,key=value::message | ||||
|  * | ||||
|  * Examples: | ||||
|  *   ##[warning]This is the user warning message | ||||
|  *   ##[set-secret name=mypassword]definitelyNotAPassword! | ||||
|  *   ::warning::This is the message | ||||
|  *   ::set-env name=MY_VAR::some value | ||||
|  */ | ||||
| function issueCommand(command, properties, message) { | ||||
|     const cmd = new Command(command, properties, message); | ||||
| @ -779,34 +1116,53 @@ class Command { | ||||
|         let cmdStr = CMD_STRING + this.command; | ||||
|         if (this.properties && Object.keys(this.properties).length > 0) { | ||||
|             cmdStr += ' '; | ||||
|             let first = true; | ||||
|             for (const key in this.properties) { | ||||
|                 if (this.properties.hasOwnProperty(key)) { | ||||
|                     const val = this.properties[key]; | ||||
|                     if (val) { | ||||
|                         // safely append the val - avoid blowing up when attempting to
 | ||||
|                         // call .replace() if message is not a string for some reason
 | ||||
|                         cmdStr += `${key}=${escape(`${val || ''}`)},`; | ||||
|                         if (first) { | ||||
|                             first = false; | ||||
|                         } | ||||
|                         else { | ||||
|                             cmdStr += ','; | ||||
|                         } | ||||
|                         cmdStr += `${key}=${escapeProperty(val)}`; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         cmdStr += CMD_STRING; | ||||
|         // safely append the message - avoid blowing up when attempting to
 | ||||
|         // call .replace() if message is not a string for some reason
 | ||||
|         const message = `${this.message || ''}`; | ||||
|         cmdStr += escapeData(message); | ||||
|         cmdStr += `${CMD_STRING}${escapeData(this.message)}`; | ||||
|         return cmdStr; | ||||
|     } | ||||
| } | ||||
| function escapeData(s) { | ||||
|     return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); | ||||
| /** | ||||
|  * Sanitizes an input into a string so it can be passed into issueCommand safely | ||||
|  * @param input input to sanitize into a string | ||||
|  */ | ||||
| function toCommandValue(input) { | ||||
|     if (input === null || input === undefined) { | ||||
|         return ''; | ||||
|     } | ||||
|     else if (typeof input === 'string' || input instanceof String) { | ||||
|         return input; | ||||
|     } | ||||
|     return JSON.stringify(input); | ||||
| } | ||||
| function escape(s) { | ||||
|     return s | ||||
| exports.toCommandValue = toCommandValue; | ||||
| function escapeData(s) { | ||||
|     return toCommandValue(s) | ||||
|         .replace(/%/g, '%25') | ||||
|         .replace(/\r/g, '%0D') | ||||
|         .replace(/\n/g, '%0A'); | ||||
| } | ||||
| function escapeProperty(s) { | ||||
|     return toCommandValue(s) | ||||
|         .replace(/%/g, '%25') | ||||
|         .replace(/\r/g, '%0D') | ||||
|         .replace(/\n/g, '%0A') | ||||
|         .replace(/]/g, '%5D') | ||||
|         .replace(/;/g, '%3B'); | ||||
|         .replace(/:/g, '%3A') | ||||
|         .replace(/,/g, '%2C'); | ||||
| } | ||||
| //# sourceMappingURL=command.js.map
 | ||||
| 
 | ||||
| @ -826,10 +1182,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     if (mod && mod.__esModule) return mod; | ||||
|     var result = {}; | ||||
|     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||||
|     result["default"] = mod; | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const command_1 = __webpack_require__(431); | ||||
| const os = __webpack_require__(87); | ||||
| const path = __webpack_require__(622); | ||||
| const os = __importStar(__webpack_require__(87)); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| /** | ||||
|  * The code to exit an action | ||||
|  */ | ||||
| @ -850,11 +1213,13 @@ var ExitCode; | ||||
| /** | ||||
|  * Sets env variable for this action and future actions in the job | ||||
|  * @param name the name of the variable to set | ||||
|  * @param val the value of the variable | ||||
|  * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify | ||||
|  */ | ||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any
 | ||||
| function exportVariable(name, val) { | ||||
|     process.env[name] = val; | ||||
|     command_1.issueCommand('set-env', { name }, val); | ||||
|     const convertedVal = command_1.toCommandValue(val); | ||||
|     process.env[name] = convertedVal; | ||||
|     command_1.issueCommand('set-env', { name }, convertedVal); | ||||
| } | ||||
| exports.exportVariable = exportVariable; | ||||
| /** | ||||
| @ -893,12 +1258,22 @@ exports.getInput = getInput; | ||||
|  * Sets the value of an output. | ||||
|  * | ||||
|  * @param     name     name of the output to set | ||||
|  * @param     value    value to store | ||||
|  * @param     value    value to store. Non-string values will be converted to a string via JSON.stringify | ||||
|  */ | ||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any
 | ||||
| function setOutput(name, value) { | ||||
|     command_1.issueCommand('set-output', { name }, value); | ||||
| } | ||||
| exports.setOutput = setOutput; | ||||
| /** | ||||
|  * Enables or disables the echoing of commands into stdout for the rest of the step. | ||||
|  * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set. | ||||
|  * | ||||
|  */ | ||||
| function setCommandEcho(enabled) { | ||||
|     command_1.issue('echo', enabled ? 'on' : 'off'); | ||||
| } | ||||
| exports.setCommandEcho = setCommandEcho; | ||||
| //-----------------------------------------------------------------------
 | ||||
| // Results
 | ||||
| //-----------------------------------------------------------------------
 | ||||
| @ -915,6 +1290,13 @@ exports.setFailed = setFailed; | ||||
| //-----------------------------------------------------------------------
 | ||||
| // Logging Commands
 | ||||
| //-----------------------------------------------------------------------
 | ||||
| /** | ||||
|  * Gets whether Actions Step Debug is on or not | ||||
|  */ | ||||
| function isDebug() { | ||||
|     return process.env['RUNNER_DEBUG'] === '1'; | ||||
| } | ||||
| exports.isDebug = isDebug; | ||||
| /** | ||||
|  * Writes debug message to user log | ||||
|  * @param message debug message | ||||
| @ -925,18 +1307,18 @@ function debug(message) { | ||||
| exports.debug = debug; | ||||
| /** | ||||
|  * Adds an error issue | ||||
|  * @param message error issue message | ||||
|  * @param message error issue message. Errors will be converted to string via toString() | ||||
|  */ | ||||
| function error(message) { | ||||
|     command_1.issue('error', message); | ||||
|     command_1.issue('error', message instanceof Error ? message.toString() : message); | ||||
| } | ||||
| exports.error = error; | ||||
| /** | ||||
|  * Adds an warning issue | ||||
|  * @param message warning issue message | ||||
|  * @param message warning issue message. Errors will be converted to string via toString() | ||||
|  */ | ||||
| function warning(message) { | ||||
|     command_1.issue('warning', message); | ||||
|     command_1.issue('warning', message instanceof Error ? message.toString() : message); | ||||
| } | ||||
| exports.warning = warning; | ||||
| /** | ||||
| @ -994,8 +1376,9 @@ exports.group = group; | ||||
|  * Saves state for current action, the state can only be retrieved by this action's post job execution. | ||||
|  * | ||||
|  * @param     name     name of the state to store | ||||
|  * @param     value    value to store | ||||
|  * @param     value    value to store. Non-string values will be converted to a string via JSON.stringify | ||||
|  */ | ||||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any
 | ||||
| function saveState(name, value) { | ||||
|     command_1.issueCommand('save-state', { name }, value); | ||||
| } | ||||
| @ -1035,6 +1418,208 @@ module.exports = require("util"); | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ 672: | ||||
| /***/ (function(__unusedmodule, exports, __webpack_require__) { | ||||
| 
 | ||||
| "use strict"; | ||||
| 
 | ||||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||||
|     function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||||
|     return new (P || (P = Promise))(function (resolve, reject) { | ||||
|         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||||
|         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||||
|         function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var _a; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const assert_1 = __webpack_require__(357); | ||||
| const fs = __webpack_require__(747); | ||||
| const path = __webpack_require__(622); | ||||
| _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; | ||||
| exports.IS_WINDOWS = process.platform === 'win32'; | ||||
| function exists(fsPath) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         try { | ||||
|             yield exports.stat(fsPath); | ||||
|         } | ||||
|         catch (err) { | ||||
|             if (err.code === 'ENOENT') { | ||||
|                 return false; | ||||
|             } | ||||
|             throw err; | ||||
|         } | ||||
|         return true; | ||||
|     }); | ||||
| } | ||||
| exports.exists = exists; | ||||
| function isDirectory(fsPath, useStat = false) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const stats = useStat ? yield exports.stat(fsPath) : yield exports.lstat(fsPath); | ||||
|         return stats.isDirectory(); | ||||
|     }); | ||||
| } | ||||
| exports.isDirectory = isDirectory; | ||||
| /** | ||||
|  * On OSX/Linux, true if path starts with '/'. On Windows, true for paths like: | ||||
|  * \, \hello, \\hello\share, C:, and C:\hello (and corresponding alternate separator cases). | ||||
|  */ | ||||
| function isRooted(p) { | ||||
|     p = normalizeSeparators(p); | ||||
|     if (!p) { | ||||
|         throw new Error('isRooted() parameter "p" cannot be empty'); | ||||
|     } | ||||
|     if (exports.IS_WINDOWS) { | ||||
|         return (p.startsWith('\\') || /^[A-Z]:/i.test(p) // e.g. \ or \hello or \\hello
 | ||||
|         ); // e.g. C: or C:\hello
 | ||||
|     } | ||||
|     return p.startsWith('/'); | ||||
| } | ||||
| exports.isRooted = isRooted; | ||||
| /** | ||||
|  * Recursively create a directory at `fsPath`. | ||||
|  * | ||||
|  * This implementation is optimistic, meaning it attempts to create the full | ||||
|  * path first, and backs up the path stack from there. | ||||
|  * | ||||
|  * @param fsPath The path to create | ||||
|  * @param maxDepth The maximum recursion depth | ||||
|  * @param depth The current recursion depth | ||||
|  */ | ||||
| function mkdirP(fsPath, maxDepth = 1000, depth = 1) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         assert_1.ok(fsPath, 'a path argument must be provided'); | ||||
|         fsPath = path.resolve(fsPath); | ||||
|         if (depth >= maxDepth) | ||||
|             return exports.mkdir(fsPath); | ||||
|         try { | ||||
|             yield exports.mkdir(fsPath); | ||||
|             return; | ||||
|         } | ||||
|         catch (err) { | ||||
|             switch (err.code) { | ||||
|                 case 'ENOENT': { | ||||
|                     yield mkdirP(path.dirname(fsPath), maxDepth, depth + 1); | ||||
|                     yield exports.mkdir(fsPath); | ||||
|                     return; | ||||
|                 } | ||||
|                 default: { | ||||
|                     let stats; | ||||
|                     try { | ||||
|                         stats = yield exports.stat(fsPath); | ||||
|                     } | ||||
|                     catch (err2) { | ||||
|                         throw err; | ||||
|                     } | ||||
|                     if (!stats.isDirectory()) | ||||
|                         throw err; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| exports.mkdirP = mkdirP; | ||||
| /** | ||||
|  * Best effort attempt to determine whether a file exists and is executable. | ||||
|  * @param filePath    file path to check | ||||
|  * @param extensions  additional file extensions to try | ||||
|  * @return if file exists and is executable, returns the file path. otherwise empty string. | ||||
|  */ | ||||
| function tryGetExecutablePath(filePath, extensions) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         let stats = undefined; | ||||
|         try { | ||||
|             // test file exists
 | ||||
|             stats = yield exports.stat(filePath); | ||||
|         } | ||||
|         catch (err) { | ||||
|             if (err.code !== 'ENOENT') { | ||||
|                 // eslint-disable-next-line no-console
 | ||||
|                 console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); | ||||
|             } | ||||
|         } | ||||
|         if (stats && stats.isFile()) { | ||||
|             if (exports.IS_WINDOWS) { | ||||
|                 // on Windows, test for valid extension
 | ||||
|                 const upperExt = path.extname(filePath).toUpperCase(); | ||||
|                 if (extensions.some(validExt => validExt.toUpperCase() === upperExt)) { | ||||
|                     return filePath; | ||||
|                 } | ||||
|             } | ||||
|             else { | ||||
|                 if (isUnixExecutable(stats)) { | ||||
|                     return filePath; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         // try each extension
 | ||||
|         const originalFilePath = filePath; | ||||
|         for (const extension of extensions) { | ||||
|             filePath = originalFilePath + extension; | ||||
|             stats = undefined; | ||||
|             try { | ||||
|                 stats = yield exports.stat(filePath); | ||||
|             } | ||||
|             catch (err) { | ||||
|                 if (err.code !== 'ENOENT') { | ||||
|                     // eslint-disable-next-line no-console
 | ||||
|                     console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); | ||||
|                 } | ||||
|             } | ||||
|             if (stats && stats.isFile()) { | ||||
|                 if (exports.IS_WINDOWS) { | ||||
|                     // preserve the case of the actual file (since an extension was appended)
 | ||||
|                     try { | ||||
|                         const directory = path.dirname(filePath); | ||||
|                         const upperName = path.basename(filePath).toUpperCase(); | ||||
|                         for (const actualName of yield exports.readdir(directory)) { | ||||
|                             if (upperName === actualName.toUpperCase()) { | ||||
|                                 filePath = path.join(directory, actualName); | ||||
|                                 break; | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                     catch (err) { | ||||
|                         // eslint-disable-next-line no-console
 | ||||
|                         console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); | ||||
|                     } | ||||
|                     return filePath; | ||||
|                 } | ||||
|                 else { | ||||
|                     if (isUnixExecutable(stats)) { | ||||
|                         return filePath; | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return ''; | ||||
|     }); | ||||
| } | ||||
| exports.tryGetExecutablePath = tryGetExecutablePath; | ||||
| function normalizeSeparators(p) { | ||||
|     p = p || ''; | ||||
|     if (exports.IS_WINDOWS) { | ||||
|         // convert slashes on Windows
 | ||||
|         p = p.replace(/\//g, '\\'); | ||||
|         // remove redundant slashes
 | ||||
|         return p.replace(/\\\\+/g, '\\'); | ||||
|     } | ||||
|     // remove redundant slashes
 | ||||
|     return p.replace(/\/\/+/g, '/'); | ||||
| } | ||||
| // on Mac/Linux, test the execute bit
 | ||||
| //     R   W  X  R  W X R W X
 | ||||
| //   256 128 64 32 16 8 4 2 1
 | ||||
| function isUnixExecutable(stats) { | ||||
|     return ((stats.mode & 1) > 0 || | ||||
|         ((stats.mode & 8) > 0 && stats.gid === process.getgid()) || | ||||
|         ((stats.mode & 64) > 0 && stats.uid === process.getuid())); | ||||
| } | ||||
| //# sourceMappingURL=io-util.js.map
 | ||||
| 
 | ||||
| /***/ }), | ||||
| 
 | ||||
| /***/ 747: | ||||
| /***/ (function(module) { | ||||
| 
 | ||||
| @ -1056,8 +1641,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | ||||
|         step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||||
|     }); | ||||
| }; | ||||
| var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     if (mod && mod.__esModule) return mod; | ||||
|     var result = {}; | ||||
|     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||||
|     result["default"] = mod; | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const tr = __webpack_require__(9); | ||||
| const tr = __importStar(__webpack_require__(9)); | ||||
| /** | ||||
|  * Exec a command. | ||||
|  * Output will be streamed to the live console. | ||||
|  | ||||
							
								
								
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -5,18 +5,19 @@ import { promisify } from 'util'; | ||||
| import { IActionArguments } from './types'; | ||||
| 
 | ||||
| const writeFileAsync = promisify(fs.writeFile); | ||||
| const errorDeploying = "⚠️ Error deploying"; | ||||
| 
 | ||||
| async function run() { | ||||
|   const userArguments = getUserArguments(); | ||||
|    | ||||
|   try { | ||||
|     const userArguments = getUserArguments(); | ||||
|      | ||||
|     await configureHost(userArguments); | ||||
|     await syncFiles(userArguments); | ||||
| 
 | ||||
|     console.log("✅ Deploy Complete"); | ||||
|   } | ||||
|   catch (error) { | ||||
|     console.error("⚠️ Error deploying"); | ||||
|     console.error(errorDeploying); | ||||
|     core.setFailed(error.message); | ||||
|   } | ||||
| } | ||||
| @ -40,7 +41,7 @@ async function configureHost(args: IActionArguments): Promise<void> { | ||||
|   } | ||||
|   catch (error) { | ||||
|     console.error("⚠️ Error configuring known_hosts"); | ||||
|     throw error; | ||||
|     core.setFailed(error.message); | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| @ -75,6 +76,5 @@ async function syncFiles(args: IActionArguments) { | ||||
|   catch (error) { | ||||
|     console.error("⚠️ Failed to upload files"); | ||||
|     core.setFailed(error.message); | ||||
|     throw error; | ||||
|   } | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user