|
1 | 1 | import { exec } from '@actions/exec';
|
2 | 2 | import ImageTag from './image-tag';
|
3 | 3 | import ImageEnvironmentFactory from './image-environment-factory';
|
| 4 | +import { existsSync, mkdirSync } from 'fs'; |
| 5 | +import path from 'path'; |
4 | 6 |
|
5 | 7 | class Docker {
|
6 | 8 | static async build(buildParameters, silent = false) {
|
7 |
| - const { path, dockerfile, baseImage } = buildParameters; |
| 9 | + const { path: buildPath, dockerfile, baseImage } = buildParameters; |
8 | 10 | const { version, platform } = baseImage;
|
9 | 11 |
|
10 | 12 | const tag = new ImageTag({ repository: '', name: 'unity-builder', version, platform });
|
11 |
| - const command = `docker build ${path} \ |
| 13 | + const command = `docker build ${buildPath} \ |
12 | 14 | --file ${dockerfile} \
|
13 | 15 | --build-arg IMAGE=${baseImage} \
|
14 | 16 | --tag ${tag}`;
|
@@ -41,16 +43,22 @@ class Docker {
|
41 | 43 |
|
42 | 44 | static getBaseOsSpecificArguments(baseOs, workspace, unitySerial, runnerTemporaryPath, sshAgent): string {
|
43 | 45 | switch (baseOs) {
|
44 |
| - case 'linux': |
| 46 | + case 'linux': { |
| 47 | + const githubHome = path.join(runnerTemporaryPath, '_github_home'); |
| 48 | + if (!existsSync(githubHome)) mkdirSync(githubHome); |
| 49 | + const githubWorkflow = path.join(runnerTemporaryPath, '_github_workflow'); |
| 50 | + if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow); |
| 51 | + |
45 | 52 | return `--env UNITY_SERIAL \
|
46 | 53 | --env GITHUB_WORKSPACE=/github/workspace \
|
47 | 54 | ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
48 |
| - --volume "/var/run/docker.sock":"/var/run/docker.sock" \ |
49 |
| - --volume "${runnerTemporaryPath}/_github_home":"/root" \ |
50 |
| - --volume "${runnerTemporaryPath}/_github_workflow":"/github/workflow" \ |
51 |
| - --volume "${workspace}":"/github/workspace" \ |
| 55 | + --volume "/var/run/docker.sock":"/var/run/docker.sock:z" \ |
| 56 | + --volume "${githubHome}":"/root:z" \ |
| 57 | + --volume "${githubWorkflow}":"/github/workflow:z" \ |
| 58 | + --volume "${workspace}":"/github/workspace:z" \ |
52 | 59 | ${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
53 | 60 | ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''}`;
|
| 61 | + } |
54 | 62 | case 'win32':
|
55 | 63 | return `--env UNITY_SERIAL="${unitySerial}" \
|
56 | 64 | --env GITHUB_WORKSPACE=c:/github/workspace \
|
|
0 commit comments