Skip to content

Commit

Permalink
sshAgent as input parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-hernandez-scopely committed May 17, 2021
1 parent 0438c9f commit cac9b2d
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 20 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ inputs:
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).
sshAgent:
required: false
default: ''
description: 'SSH Agent path to forward to the container'
chownFilesTo:
required: false
default: ''
Expand Down
19 changes: 10 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function run() {
Action.checkCompatibility();
Cache.verify();

const { dockerfile, workspace, actionFolder, sshAgent } = Action;
const { dockerfile, workspace, actionFolder } = Action;

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

Expand Down
1 change: 1 addition & 0 deletions src/model/__mocks__/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const mockGetFromUser = jest.fn().mockResolvedValue({
buildMethod: undefined,
buildVersion: '1.3.37',
customParameters: '',
sshAgent: '',
chownFilesTo: '',
});

Expand Down
4 changes: 0 additions & 4 deletions src/model/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ class Action {
return process.env.GITHUB_WORKSPACE;
}

static get sshAgent() {
return process.env.SSH_AUTH_SOCK;
}

static checkCompatibility() {
const currentPlatform = process.platform;
if (!Action.supportedPlatforms.includes(currentPlatform)) {
Expand Down
1 change: 1 addition & 0 deletions src/model/build-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class BuildParameters {
androidKeyaliasName: Input.androidKeyaliasName,
androidKeyaliasPass: Input.androidKeyaliasPass,
customParameters: Input.customParameters,
sshAgent: Input.sshAgent,
chownFilesTo: Input.chownFilesTo,
remoteBuildCluster: Input.remoteBuildCluster,
awsStackName: Input.awsStackName,
Expand Down
8 changes: 4 additions & 4 deletions src/model/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Docker {
androidKeyaliasName,
androidKeyaliasPass,
customParameters,
chownFilesTo,
sshAgent,
chownFilesTo,
} = parameters;

const command = `docker run \
Expand Down Expand Up @@ -80,13 +80,13 @@ class Docker {
--env RUNNER_TOOL_CACHE \
--env RUNNER_TEMP \
--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 "${runnerTempPath}/_github_home":"/root" \
--volume "${runnerTempPath}/_github_workflow":"/github/workflow" \
--volume "${workspace}":"/github/workspace" \
--volume "${sshAgent}":"/ssh-agent" \
--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro \
${sshAgent ? "--volume " + sshAgent + ":/ssh-agent" : ''} \
${sshAgent ? '--volume /home/runner/.ssh/known_hosts:/root/.ssh/known_hosts:ro' : ''} \
${image}`;

await exec(command, undefined, { silent });
Expand Down
4 changes: 4 additions & 0 deletions src/model/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class Input {
return core.getInput('customParameters') || '';
}

static get sshAgent() {
return core.getInput('sshAgent') || '';
}

static get chownFilesTo() {
return core.getInput('chownFilesTo') || '';
}
Expand Down

0 comments on commit cac9b2d

Please sign in to comment.