update workflow and add ssh keys support

This commit is contained in:
Shinuwa 2026-06-12 21:29:36 +02:00
parent f3a8a8d757
commit 3947df9fbb
6 changed files with 69 additions and 12 deletions

View file

@ -20,6 +20,7 @@ async function launchServer(server) {
const target = process.env[`${profile}_SSH_TARGET`];
const port = process.env[`${profile}_SSH_PORT`];
const keyFile = process.env[`${profile}_SSH_KEY_FILE`];
const command = process.env[`${profile}_START_COMMAND`];
if (!target || !command) {
@ -28,11 +29,7 @@ async function launchServer(server) {
throw error;
}
const args = [];
if (port) {
args.push("-p", port);
}
args.push(target, command);
const args = buildSshArgs({ target, port, keyFile, command });
return execFileAsync("ssh", args, {
timeout: 60_000,
@ -40,9 +37,21 @@ async function launchServer(server) {
});
}
function buildSshArgs({ target, port, keyFile, command }) {
const args = [];
if (port) {
args.push("-p", port);
}
if (keyFile) {
args.push("-i", keyFile);
}
args.push(target, command);
return args;
}
function getStartProfile(server) {
if (server.startProfile) return server.startProfile;
return "";
}
export { getStartProfile, launchServer };
export { buildSshArgs, getStartProfile, launchServer };