| 
									
										
										
										
											2020-07-31 17:27:37 +02:00
										 |  |  | import * as core from '@actions/core' | 
					
						
							|  |  |  | import {Inputs, NoFileOptions} from './constants' | 
					
						
							|  |  |  | import {UploadInputs} from './upload-inputs' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * Helper to get all the inputs for the action | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | export function getInputs(): UploadInputs { | 
					
						
							|  |  |  |   const name = core.getInput(Inputs.Name) | 
					
						
							|  |  |  |   const path = core.getInput(Inputs.Path, {required: true}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const ifNoFilesFound = core.getInput(Inputs.IfNoFilesFound) | 
					
						
							|  |  |  |   const noFileBehavior: NoFileOptions = NoFileOptions[ifNoFilesFound] | 
					
						
							| 
									
										
										
										
											2024-08-22 14:36:56 +00:00
										 |  |  |   const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles) | 
					
						
							| 
									
										
										
										
											2020-07-31 17:27:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   if (!noFileBehavior) { | 
					
						
							|  |  |  |     core.setFailed( | 
					
						
							|  |  |  |       `Unrecognized ${ | 
					
						
							|  |  |  |         Inputs.IfNoFilesFound | 
					
						
							|  |  |  |       } input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys( | 
					
						
							|  |  |  |         NoFileOptions | 
					
						
							|  |  |  |       )}`
 | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-27 13:39:36 -04:00
										 |  |  |   const inputs = { | 
					
						
							| 
									
										
										
										
											2020-07-31 17:27:37 +02:00
										 |  |  |     artifactName: name, | 
					
						
							|  |  |  |     searchPath: path, | 
					
						
							| 
									
										
										
										
											2024-08-22 14:36:56 +00:00
										 |  |  |     ifNoFilesFound: noFileBehavior, | 
					
						
							|  |  |  |     includeHiddenFiles | 
					
						
							| 
									
										
										
										
											2020-08-27 13:39:36 -04:00
										 |  |  |   } as UploadInputs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const retentionDaysStr = core.getInput(Inputs.RetentionDays) | 
					
						
							|  |  |  |   if (retentionDaysStr) { | 
					
						
							|  |  |  |     inputs.retentionDays = parseInt(retentionDaysStr) | 
					
						
							| 
									
										
										
										
											2020-09-18 16:04:35 -04:00
										 |  |  |     if (isNaN(inputs.retentionDays)) { | 
					
						
							|  |  |  |       core.setFailed('Invalid retention-days') | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-31 17:27:37 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-27 13:39:36 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return inputs | 
					
						
							| 
									
										
										
										
											2020-07-31 17:27:37 +02:00
										 |  |  | } |