support windows as well
							parent
							
								
									bab912e11e
								
							
						
					
					
						commit
						2b57369351
					
				|  | @ -3305,50 +3305,64 @@ class Docker { | |||
|     } | ||||
|     static run(image, parameters, silent = false) { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters; | ||||
|             const baseOsSpecificArguments = this.getBaseOsSpecificArguments(process.platform, workspace, actionFolder, unitySerial, runnerTempPath, sshAgent); | ||||
|             const runCommand = `docker run \
 | ||||
|     --workdir /github/workspace \ | ||||
|     --rm \ | ||||
|     ${image_environment_factory_1.default.getEnvVarString(parameters)} \ | ||||
|     ${baseOsSpecificArguments} \ | ||||
|     ${image} \ | ||||
|     /usr/bin/bash -c /entrypoint.sh`; | ||||
|             let runCommand = ''; | ||||
|             switch (process.platform) { | ||||
|                 case 'linux': | ||||
|                     runCommand = this.getLinuxCommand(image, parameters); | ||||
|                     break; | ||||
|                 case 'win32': | ||||
|                     runCommand = this.getWindowsCommand(image, parameters); | ||||
|             } | ||||
|             yield exec_1.exec(runCommand, undefined, { silent }); | ||||
|         }); | ||||
|     } | ||||
|     static getBaseOsSpecificArguments(baseOs, workspace, actionFolder, unitySerial, runnerTemporaryPath, sshAgent) { | ||||
|         switch (baseOs) { | ||||
|             case 'linux': { | ||||
|                 const githubHome = path_1.default.join(runnerTemporaryPath, '_github_home'); | ||||
|                 if (!fs_1.existsSync(githubHome)) | ||||
|                     fs_1.mkdirSync(githubHome); | ||||
|                 const githubWorkflow = path_1.default.join(runnerTemporaryPath, '_github_workflow'); | ||||
|                 if (!fs_1.existsSync(githubWorkflow)) | ||||
|                     fs_1.mkdirSync(githubWorkflow); | ||||
|                 return `--env UNITY_SERIAL \
 | ||||
|                 --env GITHUB_WORKSPACE=/github/workspace \ | ||||
|                 ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ | ||||
|                 --volume "${githubHome}":"/root:z" \ | ||||
|                 --volume "${githubWorkflow}":"/github/workflow:z" \ | ||||
|                 --volume "${workspace}":"/github/workspace:z" \ | ||||
|                 --volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \ | ||||
|                 --volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \ | ||||
|                 --volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \ | ||||
|                 ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ | ||||
|                 ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
 | ||||
|             } | ||||
|             case 'win32': | ||||
|                 return `--env UNITY_SERIAL="${unitySerial}" \
 | ||||
|                 --env GITHUB_WORKSPACE=c:/github/workspace \ | ||||
|                 --volume "${workspace}":"c:/github/workspace" \ | ||||
|                 --volume "c:/regkeys":"c:/regkeys" \ | ||||
|                 --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ | ||||
|                 --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ | ||||
|                 --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
 | ||||
|             //Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
 | ||||
|         } | ||||
|         return ''; | ||||
|     static getLinuxCommand(image, parameters) { | ||||
|         const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters; | ||||
|         const githubHome = path_1.default.join(runnerTempPath, '_github_home'); | ||||
|         if (!fs_1.existsSync(githubHome)) | ||||
|             fs_1.mkdirSync(githubHome); | ||||
|         const githubWorkflow = path_1.default.join(runnerTempPath, '_github_workflow'); | ||||
|         if (!fs_1.existsSync(githubWorkflow)) | ||||
|             fs_1.mkdirSync(githubWorkflow); | ||||
|         return `docker run \
 | ||||
|             --workdir /github/workspace \ | ||||
|             --rm \ | ||||
|             ${image_environment_factory_1.default.getEnvVarString(parameters)} \ | ||||
|             --env UNITY_SERIAL \ | ||||
|             --env GITHUB_WORKSPACE=/github/workspace \ | ||||
|             ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ | ||||
|             --volume "${githubHome}":"/root:z" \ | ||||
|             --volume "${githubWorkflow}":"/github/workflow:z" \ | ||||
|             --volume "${workspace}":"/github/workspace:z" \ | ||||
|             --volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \ | ||||
|             ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ | ||||
|             ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \ | ||||
|             ${image} \ | ||||
|             -- \ | ||||
|             /bin/bash -c /entrypoint.sh`; | ||||
|     } | ||||
|     static getWindowsCommand(image, parameters) { | ||||
|         const { workspace, actionFolder, unitySerial } = parameters; | ||||
|         return `docker run \
 | ||||
|             --workdir /github/workspace \ | ||||
|             --rm \ | ||||
|             ${image_environment_factory_1.default.getEnvVarString(parameters)} \ | ||||
|             --env UNITY_SERIAL="${unitySerial}" \ | ||||
|             --env GITHUB_WORKSPACE=c:/github/workspace \ | ||||
|             --volume "${workspace}":"c:/github/workspace" \ | ||||
|             --volume "c:/regkeys":"c:/regkeys" \ | ||||
|             --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ | ||||
|             --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ | ||||
|             --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \ | ||||
|             --volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/steps":"c:/steps" \ | ||||
|             --volume "${actionFolder}/platforms/windows/entrypoint.ps1":"c:/entrypoint.ps1" \ | ||||
|             --volume "${actionFolder}/BlankProject":"c:/BlankProject" \ | ||||
|             ${image} \ | ||||
|             -- \ | ||||
|             powershell c:/entrypoint.ps1`; | ||||
|     } | ||||
| } | ||||
| exports["default"] = Docker; | ||||
|  |  | |||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							|  | @ -21,66 +21,65 @@ class Docker { | |||
|   } | ||||
| 
 | ||||
|   static async run(image, parameters, silent = false) { | ||||
|     const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters; | ||||
| 
 | ||||
|     const baseOsSpecificArguments = this.getBaseOsSpecificArguments( | ||||
|       process.platform, | ||||
|       workspace, | ||||
|       actionFolder, | ||||
|       unitySerial, | ||||
|       runnerTempPath, | ||||
|       sshAgent, | ||||
|     ); | ||||
| 
 | ||||
|     const runCommand = `docker run \ | ||||
|     --workdir /github/workspace \ | ||||
|     --rm \ | ||||
|     ${ImageEnvironmentFactory.getEnvVarString(parameters)} \ | ||||
|     ${baseOsSpecificArguments} \ | ||||
|     ${image} \ | ||||
|     /usr/bin/bash -c /entrypoint.sh`; | ||||
| 
 | ||||
|     let runCommand = ''; | ||||
|     switch (process.platform) { | ||||
|       case 'linux': | ||||
|         runCommand = this.getLinuxCommand(image, parameters); | ||||
|         break; | ||||
|       case 'win32': | ||||
|         runCommand = this.getWindowsCommand(image, parameters); | ||||
|     } | ||||
|     await exec(runCommand, undefined, { silent }); | ||||
|   } | ||||
| 
 | ||||
|   static getBaseOsSpecificArguments( | ||||
|     baseOs, | ||||
|     workspace, | ||||
|     actionFolder, | ||||
|     unitySerial, | ||||
|     runnerTemporaryPath, | ||||
|     sshAgent, | ||||
|   ): string { | ||||
|     switch (baseOs) { | ||||
|       case 'linux': { | ||||
|         const githubHome = path.join(runnerTemporaryPath, '_github_home'); | ||||
|         if (!existsSync(githubHome)) mkdirSync(githubHome); | ||||
|         const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow'); | ||||
|         if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow); | ||||
|   static getLinuxCommand(image, parameters): string { | ||||
|     const { workspace, actionFolder, unitySerial, runnerTempPath, sshAgent } = parameters; | ||||
| 
 | ||||
|         return `--env UNITY_SERIAL \ | ||||
|                 --env GITHUB_WORKSPACE=/github/workspace \ | ||||
|                 ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ | ||||
|                 --volume "${githubHome}":"/root:z" \ | ||||
|                 --volume "${githubWorkflow}":"/github/workflow:z" \ | ||||
|                 --volume "${workspace}":"/github/workspace:z" \ | ||||
|                 --volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \ | ||||
|                 --volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \ | ||||
|                 --volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \ | ||||
|                 ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ | ||||
|                 ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
 | ||||
|       } | ||||
|       case 'win32': | ||||
|         return `--env UNITY_SERIAL="${unitySerial}" \ | ||||
|                 --env GITHUB_WORKSPACE=c:/github/workspace \ | ||||
|                 --volume "${workspace}":"c:/github/workspace" \ | ||||
|                 --volume "c:/regkeys":"c:/regkeys" \ | ||||
|                 --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ | ||||
|                 --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ | ||||
|                 --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio"`;
 | ||||
|       //Note: When upgrading to Server 2022, we will need to move to just "program files" since VS will be 64-bit
 | ||||
|     } | ||||
|     return ''; | ||||
|     const githubHome = path.join(runnerTempPath, '_github_home'); | ||||
|     if (!existsSync(githubHome)) mkdirSync(githubHome); | ||||
|     const githubWorkflow = path.join(runnerTempPath, '_github_workflow'); | ||||
|     if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow); | ||||
| 
 | ||||
|     return `docker run \ | ||||
|             --workdir /github/workspace \ | ||||
|             --rm \ | ||||
|             ${ImageEnvironmentFactory.getEnvVarString(parameters)} \ | ||||
|             --env UNITY_SERIAL \ | ||||
|             --env GITHUB_WORKSPACE=/github/workspace \ | ||||
|             ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \ | ||||
|             --volume "${githubHome}":"/root:z" \ | ||||
|             --volume "${githubWorkflow}":"/github/workflow:z" \ | ||||
|             --volume "${workspace}":"/github/workspace:z" \ | ||||
|             --volume "${actionFolder}/default-build-script:/UnityBuilderAction:z" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/steps:/steps:z" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/entrypoint.sh:/entrypoint.sh:z" \ | ||||
|             ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \ | ||||
|             ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \ | ||||
|             ${image} \ | ||||
|             -- \ | ||||
|             /bin/bash -c /entrypoint.sh`; | ||||
|   } | ||||
| 
 | ||||
|   static getWindowsCommand(image: any, parameters: any): string { | ||||
|     const { workspace, actionFolder, unitySerial } = parameters; | ||||
|     return `docker run \ | ||||
|             --workdir /github/workspace \ | ||||
|             --rm \ | ||||
|             ${ImageEnvironmentFactory.getEnvVarString(parameters)} \ | ||||
|             --env UNITY_SERIAL="${unitySerial}" \ | ||||
|             --env GITHUB_WORKSPACE=c:/github/workspace \ | ||||
|             --volume "${workspace}":"c:/github/workspace" \ | ||||
|             --volume "c:/regkeys":"c:/regkeys" \ | ||||
|             --volume "C:/Program Files (x86)/Microsoft Visual Studio":"C:/Program Files (x86)/Microsoft Visual Studio" \ | ||||
|             --volume "C:/Program Files (x86)/Windows Kits":"C:/Program Files (x86)/Windows Kits" \ | ||||
|             --volume "C:/ProgramData/Microsoft/VisualStudio":"C:/ProgramData/Microsoft/VisualStudio" \ | ||||
|             --volume "${actionFolder}/default-build-script":"c:/UnityBuilderAction" \ | ||||
|             --volume "${actionFolder}/platforms/ubuntu/steps":"c:/steps" \ | ||||
|             --volume "${actionFolder}/platforms/windows/entrypoint.ps1":"c:/entrypoint.ps1" \ | ||||
|             --volume "${actionFolder}/BlankProject":"c:/BlankProject" \ | ||||
|             ${image} \ | ||||
|             -- \ | ||||
|             powershell c:/entrypoint.ps1`; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue