mirror of
				https://github.com/actions/upload-artifact.git
				synced 2025-10-23 08:56:38 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| 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]
 | |
|   const includeHiddenFiles = core.getBooleanInput(Inputs.IncludeHiddenFiles)
 | |
| 
 | |
|   if (!noFileBehavior) {
 | |
|     core.setFailed(
 | |
|       `Unrecognized ${
 | |
|         Inputs.IfNoFilesFound
 | |
|       } input. Provided: ${ifNoFilesFound}. Available options: ${Object.keys(
 | |
|         NoFileOptions
 | |
|       )}`
 | |
|     )
 | |
|   }
 | |
| 
 | |
|   const inputs = {
 | |
|     artifactName: name,
 | |
|     searchPath: path,
 | |
|     ifNoFilesFound: noFileBehavior,
 | |
|     includeHiddenFiles
 | |
|   } as UploadInputs
 | |
| 
 | |
|   const retentionDaysStr = core.getInput(Inputs.RetentionDays)
 | |
|   if (retentionDaysStr) {
 | |
|     inputs.retentionDays = parseInt(retentionDaysStr)
 | |
|     if (isNaN(inputs.retentionDays)) {
 | |
|       core.setFailed('Invalid retention-days')
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   return inputs
 | |
| }
 |