| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  | import path from 'path'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-01-20 23:06:14 +00:00
										 |  |  | class Action { | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |   static get supportedPlatforms() { | 
					
						
							| 
									
										
										
										
											2022-01-26 04:59:41 +00:00
										 |  |  |     return ['linux', 'win32', 'darwin']; | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-22 17:07:55 +00:00
										 |  |  |   static get isRunningLocally() { | 
					
						
							|  |  |  |     return process.env.RUNNER_WORKSPACE === undefined; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static get isRunningFromSource() { | 
					
						
							| 
									
										
										
										
											2020-01-06 23:16:49 +00:00
										 |  |  |     return path.basename(__dirname) === 'model'; | 
					
						
							| 
									
										
										
										
											2019-12-22 17:07:55 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |   static get canonicalName() { | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |     return 'unity-builder'; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static get rootFolder() { | 
					
						
							| 
									
										
										
										
											2019-12-22 17:07:55 +00:00
										 |  |  |     if (Action.isRunningFromSource) { | 
					
						
							|  |  |  |       return path.dirname(path.dirname(path.dirname(__filename))); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return path.dirname(path.dirname(__filename)); | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-02-01 19:21:22 +00:00
										 |  |  |   static get actionFolder() { | 
					
						
							| 
									
										
										
										
											2021-03-13 23:44:01 +00:00
										 |  |  |     return `${Action.rootFolder}/dist`; | 
					
						
							| 
									
										
										
										
											2020-01-07 21:26:15 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |   static get dockerfile() { | 
					
						
							| 
									
										
										
										
											2022-01-25 21:18:15 +00:00
										 |  |  |     const currentPlatform = process.platform; | 
					
						
							|  |  |  |     switch (currentPlatform) { | 
					
						
							|  |  |  |       case 'linux': | 
					
						
							|  |  |  |         return `${Action.actionFolder}/platforms/ubuntu/Dockerfile`; | 
					
						
							|  |  |  |       case 'win32': | 
					
						
							|  |  |  |         return `${Action.actionFolder}/platforms/windows/Dockerfile`; | 
					
						
							| 
									
										
										
										
											2022-01-26 04:59:41 +00:00
										 |  |  |       case 'darwin': | 
					
						
							|  |  |  |         return 'unused'; //Mac doesn't use a container
 | 
					
						
							| 
									
										
										
										
											2022-01-25 21:18:15 +00:00
										 |  |  |       default: | 
					
						
							|  |  |  |         throw new Error(`No Dockerfile for currently unsupported platform: ${currentPlatform}`); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-12-22 14:05:15 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static get workspace() { | 
					
						
							|  |  |  |     return process.env.GITHUB_WORKSPACE; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static checkCompatibility() { | 
					
						
							|  |  |  |     const currentPlatform = process.platform; | 
					
						
							|  |  |  |     if (!Action.supportedPlatforms.includes(currentPlatform)) { | 
					
						
							|  |  |  |       throw new Error(`Currently ${currentPlatform}-platform is not supported`); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-01-20 23:06:14 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default Action; |