| 
									
										
										
										
											2021-12-29 15:15:39 +00:00
										 |  |  | import fs from 'fs'; | 
					
						
							| 
									
										
										
										
											2021-12-29 19:22:17 +00:00
										 |  |  | import path from 'path'; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:15:39 +00:00
										 |  |  | import YAML from 'yaml'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class ActionYamlReader { | 
					
						
							|  |  |  |   private actionYamlParsed: any; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:53:44 +00:00
										 |  |  |   public constructor() { | 
					
						
							| 
									
										
										
										
											2021-12-29 19:22:17 +00:00
										 |  |  |     let filename = `action.yml`; | 
					
						
							|  |  |  |     if (!fs.existsSync(filename)) { | 
					
						
							| 
									
										
										
										
											2021-12-29 22:01:08 +00:00
										 |  |  |       filename = path.join(__dirname, `..`, filename); | 
					
						
							| 
									
										
										
										
											2021-12-29 19:22:17 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     this.actionYamlParsed = YAML.parse(fs.readFileSync(filename).toString()); | 
					
						
							| 
									
										
										
										
											2021-12-29 15:15:39 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   public GetActionYamlValue(key: string) { | 
					
						
							| 
									
										
										
										
											2021-12-29 18:15:23 +00:00
										 |  |  |     return this.actionYamlParsed.inputs[key]?.description || 'No description found in action.yml'; | 
					
						
							| 
									
										
										
										
											2021-12-29 15:15:39 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | } |