mirror of
				https://github.com/actions/upload-artifact.git
				synced 2025-10-23 08:56:38 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import * as core from '@actions/core'
 | |
| import {Inputs} from './constants'
 | |
| import {MergeInputs} from './merge-inputs'
 | |
| 
 | |
| /**
 | |
|  * Helper to get all the inputs for the action
 | |
|  */
 | |
| export function getInputs(): MergeInputs {
 | |
|   const name = core.getInput(Inputs.Name, {required: true})
 | |
|   const pattern = core.getInput(Inputs.Pattern, {required: true})
 | |
|   const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
 | |
|   const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
 | |
|   const includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
 | |
| 
 | |
|   const inputs = {
 | |
|     name,
 | |
|     pattern,
 | |
|     separateDirectories,
 | |
|     deleteMerged,
 | |
|     retentionDays: 0,
 | |
|     compressionLevel: 6,
 | |
|     includeGitDirectory
 | |
|   } as MergeInputs
 | |
| 
 | |
|   const retentionDaysStr = core.getInput(Inputs.RetentionDays)
 | |
|   if (retentionDaysStr) {
 | |
|     inputs.retentionDays = parseInt(retentionDaysStr)
 | |
|     if (isNaN(inputs.retentionDays)) {
 | |
|       core.setFailed('Invalid retention-days')
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   const compressionLevelStr = core.getInput(Inputs.CompressionLevel)
 | |
|   if (compressionLevelStr) {
 | |
|     inputs.compressionLevel = parseInt(compressionLevelStr)
 | |
|     if (isNaN(inputs.compressionLevel)) {
 | |
|       core.setFailed('Invalid compression-level')
 | |
|     }
 | |
| 
 | |
|     if (inputs.compressionLevel < 0 || inputs.compressionLevel > 9) {
 | |
|       core.setFailed('Invalid compression-level. Valid values are 0-9')
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   return inputs
 | |
| }
 |