feat: support self-hosted runners (#170)
* feat: support self-hosted runners similar to https://github.com/game-ci/unity-builder/pull/355 * Use $RUNNER_TEMP variable instead of hardcoded path for _github_home and _github_workflow * create the folders if they don't exist * mount volumes with :z for compatibility with SELinux * compile typescript filespull/171/head
parent
174e562151
commit
79715c7e78
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -20,6 +20,7 @@ async function run() {
|
|||
checkName,
|
||||
} = Input.getFromUser();
|
||||
const baseImage = new ImageTag({ version: unityVersion, customImage });
|
||||
const runnerTempPath = process.env.RUNNER_TEMP;
|
||||
|
||||
try {
|
||||
// Build docker image
|
||||
|
@ -37,6 +38,7 @@ async function run() {
|
|||
sshAgent,
|
||||
gitPrivateToken,
|
||||
githubToken,
|
||||
runnerTempPath,
|
||||
});
|
||||
} finally {
|
||||
// Set output
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import { existsSync, mkdirSync } from 'fs';
|
||||
import ImageTag from './image-tag';
|
||||
import { exec } from '@actions/exec';
|
||||
import path from 'path';
|
||||
|
||||
const Docker = {
|
||||
async build(buildParameters, silent = false) {
|
||||
const { path, dockerfile, baseImage } = buildParameters;
|
||||
const { path: buildPath, dockerfile, baseImage } = buildParameters;
|
||||
const { version } = baseImage;
|
||||
|
||||
const tag = new ImageTag({ version });
|
||||
const command = `docker build ${path} \
|
||||
const command = `docker build ${buildPath} \
|
||||
--file ${dockerfile} \
|
||||
--build-arg IMAGE=${baseImage} \
|
||||
--tag ${tag}`;
|
||||
|
@ -29,8 +31,14 @@ const Docker = {
|
|||
sshAgent,
|
||||
gitPrivateToken,
|
||||
githubToken,
|
||||
runnerTempPath,
|
||||
} = parameters;
|
||||
|
||||
const githubHome = path.join(runnerTempPath, '_github_home');
|
||||
if (!existsSync(githubHome)) mkdirSync(githubHome);
|
||||
const githubWorkflow = path.join(runnerTempPath, '_github_workflow');
|
||||
if (!existsSync(githubWorkflow)) mkdirSync(githubWorkflow);
|
||||
|
||||
const command = `docker run \
|
||||
--workdir /github/workspace \
|
||||
--rm \
|
||||
|
@ -61,10 +69,10 @@ const Docker = {
|
|||
--env RUNNER_WORKSPACE \
|
||||
--env GIT_PRIVATE_TOKEN="${gitPrivateToken}" \
|
||||
${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
|
||||
--volume "/var/run/docker.sock":"/var/run/docker.sock" \
|
||||
--volume "/home/runner/work/_temp/_github_home":"/root" \
|
||||
--volume "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
|
||||
--volume "${workspace}":"/github/workspace" \
|
||||
--volume "/var/run/docker.sock":"/var/run/docker.sock:z" \
|
||||
--volume "${githubHome}":"/root:z" \
|
||||
--volume "${githubWorkflow}":"/github/workflow:z" \
|
||||
--volume "${workspace}":"/github/workspace:z" \
|
||||
${sshAgent ? `--volume ${sshAgent}:/ssh-agent` : ''} \
|
||||
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
|
||||
${useHostNetwork ? '--net=host' : ''} \
|
||||
|
|
Loading…
Reference in New Issue