Skip to content

Commit ad4e785

Browse files
Add ssh-config input (#11)
Closes #10
1 parent 4b3c564 commit ad4e785

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
with:
77
private-key: ${{ secrets.PRIVATE_KEY }}
88
known-hosts: ${{ secrets.KNOWN_HOSTS }}
9+
ssh-config: ${{ secrets.SSH_CONFIG }}
910
dep: deploy prod -v
1011
```
1112
1213
## Inputs
1314
1415
- `private-key` - Required. A private key to accessing servers.
15-
- `known-hosts` - Optional. Host fingerprints. If omitted `StrictHostKeyChecking=no` will be used.
16+
- `known-hosts` - Optional. Host fingerprints. If omitted `StrictHostKeyChecking=no` will be used unless `ssh-config` is provided.
17+
- `ssh-config` - Optional. SSH configuration.
1618
- `dep` - Required. Arguments to pass to Deployer command.
1719

1820
## Deployer version
@@ -41,5 +43,6 @@ deploy:
4143
with:
4244
private-key: ${{ secrets.PRIVATE_KEY }}
4345
known-hosts: ${{ secrets.KNOWN_HOSTS }}
46+
ssh-config: ${{ secrets.SSH_CONFIG }}
4447
dep: deploy prod -v
4548
```

action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
description: 'Known hosts'
99
required: false
1010
default: ''
11+
ssh-config:
12+
description: 'SSH configuration'
13+
required: false
14+
default: ''
1115
dep:
1216
description: 'Deployer command'
1317
required: false

index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ function ssh() {
2626
let privateKey = core.getInput('private-key').replace('/\r/g', '').trim() + '\n'
2727
execa.sync('ssh-add', ['-'], {input: privateKey})
2828

29-
let knownHosts = core.getInput('known-hosts')
30-
if (knownHosts === '') {
31-
fs.appendFileSync(`${ssh}/config`, `StrictHostKeyChecking no`)
32-
} else {
29+
const knownHosts = core.getInput('known-hosts')
30+
if (knownHosts !== '') {
3331
fs.appendFileSync(`${ssh}/known_hosts`, knownHosts)
3432
fs.chmodSync(`${ssh}/known_hosts`, '644')
33+
} else {
34+
fs.appendFileSync(`${ssh}/config`, `StrictHostKeyChecking no`)
35+
}
36+
37+
const sshConfig = core.getInput('ssh-config')
38+
if (sshConfig !== '') {
39+
fs.writeFile(`${ssh}/config`, sshConfig)
3540
}
3641
}
3742

0 commit comments

Comments
 (0)