sshAgent as input parameter

pull/256/head
Ivan Hernandez 2021-05-17 16:10:42 +02:00
parent 27f6f54c06
commit c75e11dc6a
7 changed files with 16 additions and 10 deletions

View File

@ -106,6 +106,10 @@ inputs:
Parameters must start with a hyphen (-) and may be followed by a value (without hyphen). Parameters must start with a hyphen (-) and may be followed by a value (without hyphen).
Parameters without a value will be considered booleans (with a value of true). Parameters without a value will be considered booleans (with a value of true).
sshAgent:
required: false
default: ''
description: 'SSH Agent path to forward to the container'
chownFilesTo: chownFilesTo:
required: false required: false
default: '' default: ''

View File

@ -6,7 +6,7 @@ async function run() {
Action.checkCompatibility(); Action.checkCompatibility();
Cache.verify(); Cache.verify();
const { dockerfile, workspace, actionFolder, sshAgent } = Action; const { dockerfile, workspace, actionFolder } = Action;
const buildParameters = await BuildParameters.create(); const buildParameters = await BuildParameters.create();
const baseImage = new ImageTag(buildParameters); const baseImage = new ImageTag(buildParameters);
@ -27,7 +27,7 @@ async function run() {
default: default:
core.info('Building locally'); core.info('Building locally');
builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage }); builtImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
await Docker.run(builtImage, { workspace, sshAgent, ...buildParameters }); await Docker.run(builtImage, { workspace, ...buildParameters });
break; break;
} }

View File

@ -10,6 +10,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
buildMethod: undefined, buildMethod: undefined,
buildVersion: '1.3.37', buildVersion: '1.3.37',
customParameters: '', customParameters: '',
sshAgent: '',
chownFilesTo: '', chownFilesTo: '',
}); });

View File

@ -37,10 +37,6 @@ class Action {
return process.env.GITHUB_WORKSPACE; return process.env.GITHUB_WORKSPACE;
} }
static get sshAgent() {
return process.env.SSH_AUTH_SOCK;
}
static checkCompatibility() { static checkCompatibility() {
const currentPlatform = process.platform; const currentPlatform = process.platform;
if (!Action.supportedPlatforms.includes(currentPlatform)) { if (!Action.supportedPlatforms.includes(currentPlatform)) {

View File

@ -60,6 +60,7 @@ class BuildParameters {
androidKeyaliasName: Input.androidKeyaliasName, androidKeyaliasName: Input.androidKeyaliasName,
androidKeyaliasPass: Input.androidKeyaliasPass, androidKeyaliasPass: Input.androidKeyaliasPass,
customParameters: Input.customParameters, customParameters: Input.customParameters,
sshAgent: Input.sshAgent,
chownFilesTo: Input.chownFilesTo, chownFilesTo: Input.chownFilesTo,
remoteBuildCluster: Input.remoteBuildCluster, remoteBuildCluster: Input.remoteBuildCluster,
awsStackName: Input.awsStackName, awsStackName: Input.awsStackName,

View File

@ -36,8 +36,8 @@ class Docker {
androidKeyaliasName, androidKeyaliasName,
androidKeyaliasPass, androidKeyaliasPass,
customParameters, customParameters,
chownFilesTo,
sshAgent, sshAgent,
chownFilesTo,
} = parameters; } = parameters;
const command = `docker run \ const command = `docker run \
@ -80,13 +80,13 @@ class Docker {
--env RUNNER_TOOL_CACHE \ --env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \ --env RUNNER_TEMP \
--env RUNNER_WORKSPACE \ --env RUNNER_WORKSPACE \
--env SSH_AUTH_SOCK=/ssh-agent \ ${sshAgent ? '--env SSH_AUTH_SOCK=/ssh-agent' : ''} \
--volume "/var/run/docker.sock":"/var/run/docker.sock" \ --volume "/var/run/docker.sock":"/var/run/docker.sock" \
--volume "${runnerTempPath}/_github_home":"/root" \ --volume "${runnerTempPath}/_github_home":"/root" \
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \ --volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \ --volume "${workspace}":"/github/workspace" \
--volume "${sshAgent}":"/ssh-agent" \ ${sshAgent ? "--volume " + sshAgent + ":/ssh-agent" : ''} \
--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro \ ${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${image}`; ${image}`;
await exec(command, undefined, { silent }); await exec(command, undefined, { silent });

View File

@ -85,6 +85,10 @@ class Input {
return core.getInput('customParameters') || ''; return core.getInput('customParameters') || '';
} }
static get sshAgent() {
return core.getInput('sshAgent') || '';
}
static get chownFilesTo() { static get chownFilesTo() {
return core.getInput('chownFilesTo') || ''; return core.getInput('chownFilesTo') || '';
} }