Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions setup-discovery-ssh/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ runs:
DISCOVERY_USER_NAME: ${{ inputs.user_name }}
DISCOVERY_SSH_KNOWN_HOSTS_ENTRY: ${{ inputs.ssh_known_hosts_entry }}
DISCOVERY_SSH_KEY: ${{ inputs.ssh_key }}

runs:
using: 'node16'
main: 'setup.js'
post: 'cleanup.js'
11 changes: 11 additions & 0 deletions setup-discovery-ssh/cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const core = require("@actions/core");

async function run() {
try {
process.kill(process.env.STATE_SSH_AGENT_PID);
} catch (error) {
core.setFailed(error.message);
}
}

run();
23 changes: 23 additions & 0 deletions setup-discovery-ssh/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as fs from "fs";
import * as os from "os";
import * as path from "path";

import * as core from "@actions/core";
import * as exec from "@actions/exec";

async function run() {
try {
core.exportVariable("DISCOVERY_USER_NAME", core.getInput("user_name"));
core.exportVariable(
"DISCOVERY_SSH_KNOWN_HOSTS_ENTRY",
core.getInput("ssh_known_hosts_entry")
);
core.exportVariable("DISCOVERY_SSH_KEY", core.getInput("ssh_key"));
// await exec.exec(path.resolve(__dirname, "setup.sh"), []);
await exec.exec(path.resolve(__dirname, "setup.sh"));
} catch (error) {
core.setFailed(error.message);
}
}

run();
2 changes: 2 additions & 0 deletions setup-discovery-ssh/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ if ssh-keygen -y -f "$ssh_key_file" &>/dev/null; then
ssh-add -q "$ssh_key_file" && rm "$ssh_key_file"
# Auth agent socket to ssh config
echo "IdentityAgent $SSH_AUTH_SOCK" >> "$SSH_CONFIG_FILE"
# Save pid to cleanup in post step
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> "$GITHUB_STATE"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So later GHA export that automatically?

else
echo -e >&2 \
"Your SSH key is not a valid OpenSSH private key\n"\
Expand Down