Express logging flag in a "positive" way, not as "do not log"

This commit is contained in:
Matthias Pigulla 2022-10-19 10:26:23 +00:00
parent b5b046356c
commit 3d2f9b9e54
No known key found for this signature in database
GPG key ID: 07625DB0815D6CA1
3 changed files with 6 additions and 6 deletions

View file

@ -6,10 +6,10 @@ inputs:
required: true required: true
ssh-auth-sock: ssh-auth-sock:
description: 'Where to place the SSH Agent auth socket' description: 'Where to place the SSH Agent auth socket'
dont-log-public-key: log-public-key:
description: 'Whether or not to log public key fingerprints' description: 'Whether or not to log public key fingerprints'
required: false required: false
default: false default: true
runs: runs:
using: 'node12' using: 'node12'
main: 'dist/index.js' main: 'dist/index.js'

4
dist/index.js vendored
View file

@ -326,7 +326,7 @@ const { home, sshAgent, sshAdd } = __webpack_require__(972);
try { try {
const privateKey = core.getInput('ssh-private-key'); const privateKey = core.getInput('ssh-private-key');
const dontLogPublicKey = core.getBooleanInput('dont-log-public-key', {default: false}); const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
if (!privateKey) { if (!privateKey) {
core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file."); core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file.");
@ -375,7 +375,7 @@ try {
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i); const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
if (!parts) { if (!parts) {
if (!dontLogPublicKey) { if (logPublicKey) {
console.log(`Comment for (public) key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`); console.log(`Comment for (public) key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`);
} }
return; return;

View file

@ -6,7 +6,7 @@ const { home, sshAgent, sshAdd } = require('./paths.js');
try { try {
const privateKey = core.getInput('ssh-private-key'); const privateKey = core.getInput('ssh-private-key');
const dontLogPublicKey = core.getBooleanInput('dont-log-public-key', {default: false}); const logPublicKey = core.getBooleanInput('log-public-key', {default: true});
if (!privateKey) { if (!privateKey) {
core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file."); core.setFailed("The ssh-private-key argument is empty. Maybe the secret has not been configured, or you are using a wrong secret name in your workflow file.");
@ -55,7 +55,7 @@ try {
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i); const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/i);
if (!parts) { if (!parts) {
if (!dontLogPublicKey) { if (logPublicKey) {
console.log(`Comment for (public) key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`); console.log(`Comment for (public) key '${key}' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.`);
} }
return; return;