Add ssh-config input (#11)

Closes #10
This commit is contained in:
Benoît Chantre 2021-05-01 11:32:31 +02:00 committed by GitHub
commit ad4e7856ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View file

@ -26,12 +26,17 @@ function ssh() {
let privateKey = core.getInput('private-key').replace('/\r/g', '').trim() + '\n'
execa.sync('ssh-add', ['-'], {input: privateKey})
let knownHosts = core.getInput('known-hosts')
if (knownHosts === '') {
fs.appendFileSync(`${ssh}/config`, `StrictHostKeyChecking no`)
} else {
const knownHosts = core.getInput('known-hosts')
if (knownHosts !== '') {
fs.appendFileSync(`${ssh}/known_hosts`, knownHosts)
fs.chmodSync(`${ssh}/known_hosts`, '644')
} else {
fs.appendFileSync(`${ssh}/config`, `StrictHostKeyChecking no`)
}
const sshConfig = core.getInput('ssh-config')
if (sshConfig !== '') {
fs.writeFile(`${ssh}/config`, sshConfig)
}
}