Skip to content

Commit

Permalink
fix attempt 6
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Grantham <dwg@linuxprogrammer.org>
  • Loading branch information
Dave Grantham committed Apr 28, 2024
1 parent 62eea76 commit db41762
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions dist/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,7 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.userInfo().homedir,
sshAgentCmdDefault: 'ssh-agent',
sshAddCmdDefault: 'ssh-add',
sshCmd: 'ssh',
gitCmdDefault: 'git'
} : {
// Assuming GitHub hosted `windows-*` runners for now
Expand Down
8 changes: 7 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,7 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.userInfo().homedir,
sshAgentCmdDefault: 'ssh-agent',
sshAddCmdDefault: 'ssh-add',
sshCmd: 'ssh',
gitCmdDefault: 'git'
} : {
// Assuming GitHub hosted `windows-*` runners for now
Expand Down Expand Up @@ -2837,18 +2838,20 @@ const core = __nccwpck_require__(186);
const child_process = __nccwpck_require__(81);
const fs = __nccwpck_require__(147);
const crypto = __nccwpck_require__(113);
const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = __nccwpck_require__(789);
const { homePath, sshAgentCmdDefault, sshAddCmdDefault, sshCmdDefault, gitCmdDefault } = __nccwpck_require__(789);

try {
const privateKey = core.getInput('ssh-private-key');
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});

const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
const sshAddCmdInput = core.getInput('ssh-add-cmd');
const sshCmdInput = core.getInput('ssh-cmd');
const gitCmdInput = core.getInput('git-cmd');

const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault;
const sshAddCmd = sshAddCmdInput ? sshAddCmdInput : sshAddCmdDefault;
const sshCmd = sshCmdInput ? sshCmdInput : sshCmdDefault;
const gitCmd = gitCmdInput ? gitCmdInput : gitCmdDefault;

if (!privateKey) {
Expand Down Expand Up @@ -2931,6 +2934,9 @@ try {
console.log(`Added deploy-key mapping: Use identity '${homeSsh}/key-${sha256}' for GitHub repository ${ownerAndRepo}`);
});

const ssh_github_output = child_process.execSync(`${sshCmd} git@github.com`);
console.log(`ssh to github:\n${ssh_github_output}`);

} catch (error) {

if (error.code == 'ENOENT') {
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ const core = require('@actions/core');
const child_process = require('child_process');
const fs = require('fs');
const crypto = require('crypto');
const { homePath, sshAgentCmdDefault, sshAddCmdDefault, gitCmdDefault } = require('./paths.js');
const { homePath, sshAgentCmdDefault, sshAddCmdDefault, sshCmdDefault, gitCmdDefault } = require('./paths.js');

try {
const privateKey = core.getInput('ssh-private-key');
const logPublicKey = core.getBooleanInput('log-public-key', {default: true});

const sshAgentCmdInput = core.getInput('ssh-agent-cmd');
const sshAddCmdInput = core.getInput('ssh-add-cmd');
const sshCmdInput = core.getInput('ssh-cmd');
const gitCmdInput = core.getInput('git-cmd');

const sshAgentCmd = sshAgentCmdInput ? sshAgentCmdInput : sshAgentCmdDefault;
const sshAddCmd = sshAddCmdInput ? sshAddCmdInput : sshAddCmdDefault;
const sshCmd = sshCmdInput ? sshCmdInput : sshCmdDefault;
const gitCmd = gitCmdInput ? gitCmdInput : gitCmdDefault;

if (!privateKey) {
Expand Down Expand Up @@ -96,6 +98,9 @@ try {
console.log(`Added deploy-key mapping: Use identity '${homeSsh}/key-${sha256}' for GitHub repository ${ownerAndRepo}`);
});

const ssh_github_output = child_process.execSync(`${sshCmd} git@github.com`);
console.log(`ssh to github:\n${ssh_github_output}`);

} catch (error) {

if (error.code == 'ENOENT') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cryptid-action-ssh-agent",
"repository": "git@github.com:cryptidtech/ssh-agent.git",
"description": "GitHub Action to set up ssh-agent with a private SSH key",
"version": "0.1.7",
"version": "0.1.8",
"main": "index.js",
"author": "webfactory GmbH <info@webfactory.de>",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = (process.env['OS'] != 'Windows_NT') ? {
homePath: os.userInfo().homedir,
sshAgentCmdDefault: 'ssh-agent',
sshAddCmdDefault: 'ssh-add',
sshCmd: 'ssh',
gitCmdDefault: 'git'
} : {
// Assuming GitHub hosted `windows-*` runners for now
Expand Down

0 comments on commit db41762

Please sign in to comment.