mirror of
https://github.com/shimataro/ssh-key-action.git
synced 2025-06-19 22:52:10 +10:00
use known_hosts: no
instead of no_known_hosts: true
This commit is contained in:
parent
712085029d
commit
c31b1e4544
8 changed files with 10 additions and 64 deletions
|
@ -317,6 +317,6 @@ jobs:
|
||||||
uses: ./.
|
uses: ./.
|
||||||
with:
|
with:
|
||||||
key: ${{ secrets.SSH_KEY_PEM }}
|
key: ${{ secrets.SSH_KEY_PEM }}
|
||||||
no_known_hosts: true
|
known_hosts: no
|
||||||
- name: print created files
|
- name: print created files
|
||||||
run: ls -l /root/.ssh
|
run: ls -l /root/.ssh
|
||||||
|
|
|
@ -337,6 +337,6 @@ jobs:
|
||||||
uses: ./.
|
uses: ./.
|
||||||
with:
|
with:
|
||||||
key: ${{ secrets.SSH_KEY_PEM }}
|
key: ${{ secrets.SSH_KEY_PEM }}
|
||||||
no_known_hosts: true
|
known_hosts: no
|
||||||
- name: print created files
|
- name: print created files
|
||||||
run: ls -l /root/.ssh
|
run: ls -l /root/.ssh
|
||||||
|
|
2
.github/workflows/verify-on-macos.yml
vendored
2
.github/workflows/verify-on-macos.yml
vendored
|
@ -255,6 +255,6 @@ jobs:
|
||||||
uses: ./.
|
uses: ./.
|
||||||
with:
|
with:
|
||||||
key: ${{ secrets.SSH_KEY_PEM }}
|
key: ${{ secrets.SSH_KEY_PEM }}
|
||||||
no_known_hosts: true
|
known_hosts: no
|
||||||
- name: print created files
|
- name: print created files
|
||||||
run: ls -l ~/.ssh
|
run: ls -l ~/.ssh
|
||||||
|
|
2
.github/workflows/verify-on-ubuntu.yml
vendored
2
.github/workflows/verify-on-ubuntu.yml
vendored
|
@ -275,6 +275,6 @@ jobs:
|
||||||
uses: ./.
|
uses: ./.
|
||||||
with:
|
with:
|
||||||
key: ${{ secrets.SSH_KEY_PEM }}
|
key: ${{ secrets.SSH_KEY_PEM }}
|
||||||
no_known_hosts: true
|
known_hosts: no
|
||||||
- name: print created files
|
- name: print created files
|
||||||
run: ls -l ~/.ssh
|
run: ls -l ~/.ssh
|
||||||
|
|
2
.github/workflows/verify-on-windows.yml
vendored
2
.github/workflows/verify-on-windows.yml
vendored
|
@ -255,6 +255,6 @@ jobs:
|
||||||
uses: ./.
|
uses: ./.
|
||||||
with:
|
with:
|
||||||
key: ${{ secrets.SSH_KEY_PEM }}
|
key: ${{ secrets.SSH_KEY_PEM }}
|
||||||
no_known_hosts: true
|
known_hosts: no
|
||||||
- name: print created files
|
- name: print created files
|
||||||
run: ls -l ~/.ssh
|
run: ls -l ~/.ssh
|
||||||
|
|
|
@ -14,7 +14,7 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: "id_rsa"
|
default: "id_rsa"
|
||||||
known_hosts:
|
known_hosts:
|
||||||
description: "public keys of SSH servers"
|
description: "public keys of SSH servers, or set to 'no' in order to omit it"
|
||||||
required: true
|
required: true
|
||||||
default: ""
|
default: ""
|
||||||
config:
|
config:
|
||||||
|
@ -25,10 +25,6 @@ inputs:
|
||||||
description: "replace / ignore / fail"
|
description: "replace / ignore / fail"
|
||||||
required: false
|
required: false
|
||||||
default: "fail"
|
default: "fail"
|
||||||
no_known_hosts:
|
|
||||||
description: "enables not providing known_hosts file"
|
|
||||||
required: false
|
|
||||||
default: "0"
|
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: "node12"
|
||||||
main: "lib/index.js"
|
main: "lib/index.js"
|
||||||
|
|
26
lib/index.js
26
lib/index.js
|
@ -428,13 +428,12 @@ const core = __importStar(__nccwpck_require__(186));
|
||||||
function main() {
|
function main() {
|
||||||
try {
|
try {
|
||||||
// parameters
|
// parameters
|
||||||
const noKnownHosts = string2boolean(core.getInput("no_known_hosts"));
|
|
||||||
const key = core.getInput("key", {
|
const key = core.getInput("key", {
|
||||||
required: true,
|
required: true,
|
||||||
});
|
});
|
||||||
const name = core.getInput("name");
|
const name = core.getInput("name");
|
||||||
const knownHosts = core.getInput("known_hosts", {
|
const knownHosts = core.getInput("known_hosts", {
|
||||||
required: !noKnownHosts, // optional if no_known_hosts is true
|
required: true,
|
||||||
});
|
});
|
||||||
const config = core.getInput("config");
|
const config = core.getInput("config");
|
||||||
const ifKeyExists = core.getInput("if_key_exists");
|
const ifKeyExists = core.getInput("if_key_exists");
|
||||||
|
@ -457,7 +456,7 @@ function main() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (knownHosts !== "") {
|
if (knownHosts !== "no") {
|
||||||
files.push({
|
files.push({
|
||||||
name: "known_hosts",
|
name: "known_hosts",
|
||||||
contents: insertLf(knownHosts, true, true),
|
contents: insertLf(knownHosts, true, true),
|
||||||
|
@ -488,27 +487,6 @@ function main() {
|
||||||
core.setFailed(err.message);
|
core.setFailed(err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* convert string to boolean
|
|
||||||
* @param value string value
|
|
||||||
* @returns boolean value
|
|
||||||
*/
|
|
||||||
function string2boolean(value) {
|
|
||||||
// true if "true" / "yes" / "on"
|
|
||||||
switch (value.trim().toLowerCase()) {
|
|
||||||
case "true":
|
|
||||||
case "yes":
|
|
||||||
case "on":
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// true if number and non-zero
|
|
||||||
const numberValue = Number(value);
|
|
||||||
if (!isNaN(numberValue) && numberValue !== 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// false otherwise
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* get home directory
|
* get home directory
|
||||||
* @returns home directory
|
* @returns home directory
|
||||||
|
|
32
src/main.ts
32
src/main.ts
|
@ -18,13 +18,12 @@ function main(): void
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// parameters
|
// parameters
|
||||||
const noKnownHosts = string2boolean(core.getInput("no_known_hosts"));
|
|
||||||
const key = core.getInput("key", {
|
const key = core.getInput("key", {
|
||||||
required: true,
|
required: true,
|
||||||
});
|
});
|
||||||
const name = core.getInput("name");
|
const name = core.getInput("name");
|
||||||
const knownHosts = core.getInput("known_hosts", {
|
const knownHosts = core.getInput("known_hosts", {
|
||||||
required: !noKnownHosts, // optional if no_known_hosts is true
|
required: true,
|
||||||
});
|
});
|
||||||
const config = core.getInput("config");
|
const config = core.getInput("config");
|
||||||
const ifKeyExists = core.getInput("if_key_exists");
|
const ifKeyExists = core.getInput("if_key_exists");
|
||||||
|
@ -50,7 +49,7 @@ function main(): void
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(knownHosts !== "")
|
if(knownHosts !== "no")
|
||||||
{
|
{
|
||||||
files.push({
|
files.push({
|
||||||
name: "known_hosts",
|
name: "known_hosts",
|
||||||
|
@ -88,33 +87,6 @@ function main(): void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* convert string to boolean
|
|
||||||
* @param value string value
|
|
||||||
* @returns boolean value
|
|
||||||
*/
|
|
||||||
function string2boolean(value: string): boolean
|
|
||||||
{
|
|
||||||
// true if "true" / "yes" / "on"
|
|
||||||
switch(value.trim().toLowerCase())
|
|
||||||
{
|
|
||||||
case "true":
|
|
||||||
case "yes":
|
|
||||||
case "on":
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// true if number and non-zero
|
|
||||||
const numberValue = Number(value);
|
|
||||||
if(!isNaN(numberValue) && numberValue !== 0)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// false otherwise
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get home directory
|
* get home directory
|
||||||
* @returns home directory
|
* @returns home directory
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue