Skip to content

Commit 4d571a0

Browse files
committed
npm run build
Signed-off-by: Johannes Schindelin <[email protected]>
1 parent ff35d61 commit 4d571a0

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lib/index.js

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12630,7 +12630,10 @@ async function run() {
1263012630
}
1263112631

1263212632
let newSessionExtra = ""
12633-
if (core.getInput("limit-access-to-actor") === "true") {
12633+
let tmateSSHDashI = ""
12634+
let publicSSHKeysWarning = ""
12635+
const limitAccessToActor = core.getInput("limit-access-to-actor")
12636+
if (limitAccessToActor === "true" || limitAccessToActor === "auto") {
1263412637
const { actor, apiUrl } = github.context
1263512638
const auth = core.getInput('github-token')
1263612639
const octokit = new dist_node/* Octokit */.v({ auth, baseUrl: apiUrl })
@@ -12639,13 +12642,16 @@ async function run() {
1263912642
username: actor
1264012643
})
1264112644
if (keys.data.length === 0) {
12642-
throw new Error(`No public SSH keys registered with ${actor}'s GitHub profile`)
12645+
if (limitAccessToActor === "auto") publicSSHKeysWarning = `No public SSH keys found for ${actor}; continuing without them even if it is less secure (please consider adding an SSH key, see https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)`
12646+
else throw new Error(`No public SSH keys registered with ${actor}'s GitHub profile`)
12647+
} else {
12648+
const sshPath = external_path_default().join(external_os_default().homedir(), ".ssh")
12649+
await external_fs_default().promises.mkdir(sshPath, { recursive: true })
12650+
const authorizedKeysPath = external_path_default().join(sshPath, "authorized_keys")
12651+
await external_fs_default().promises.writeFile(authorizedKeysPath, keys.data.map(e => e.key).join('\n'))
12652+
newSessionExtra = `-a "${authorizedKeysPath}"`
12653+
tmateSSHDashI = "ssh -i <path-to-private-SSH-key>"
1264312654
}
12644-
const sshPath = external_path_default().join(external_os_default().homedir(), ".ssh")
12645-
await external_fs_default().promises.mkdir(sshPath, { recursive: true })
12646-
const authorizedKeysPath = external_path_default().join(sshPath, "authorized_keys")
12647-
await external_fs_default().promises.writeFile(authorizedKeysPath, keys.data.map(e => e.key).join('\n'))
12648-
newSessionExtra = `-a "${authorizedKeysPath}"`
1264912655
}
1265012656

1265112657
const tmate = `${tmateExecutable} -S /tmp/tmate.sock`;
@@ -12684,10 +12690,16 @@ async function run() {
1268412690

1268512691
core.debug("Entering main loop")
1268612692
while (true) {
12693+
if (publicSSHKeysWarning) {
12694+
core.warning(publicSSHKeysWarning)
12695+
}
1268712696
if (tmateWeb) {
1268812697
core.info(`Web shell: ${tmateWeb}`);
1268912698
}
1269012699
core.info(`SSH: ${tmateSSH}`);
12700+
if (tmateSSHDashI) {
12701+
core.info(`or: ${tmateSSH.replace(/^ssh/, tmateSSHDashI)}`)
12702+
}
1269112703

1269212704
if (continueFileExists()) {
1269312705
core.info("Exiting debugging session because the continue file was created")

0 commit comments

Comments
 (0)