feat: add warning_on_retry input

This commit is contained in:
Nick Fields
2020-11-18 10:25:11 -05:00
parent 0bbc6bd3b0
commit 5ee366655c
4 changed files with 20 additions and 2 deletions

View File

@@ -28,6 +28,10 @@ Retries an Action step on failure or timeout. This is currently intended to repl
**Optional** Event to retry on. Currently supports [any (default), timeout, error].
### `warning_on_retry`
**Optional** Whether to output a warning on retry, or just output to info. Defaults to `true`.
## Outputs
### `total_attempts`

View File

@@ -24,6 +24,9 @@ inputs:
default: 1
retry_on:
description: Event to retry on. Currently supported [any, timeout, error]
warning_on_retry:
description: Whether to output a warning on retry, or just output to info. Defaults to true
default: true
outputs:
total_attempts:
description: The final number of attempts made

8
dist/index.js vendored
View File

@@ -251,6 +251,7 @@ var COMMAND = core_1.getInput('command', { required: true });
var RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
var POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
var RETRY_ON = core_1.getInput('retry_on') || 'any';
var WARNING_ON_RETRY = core_1.getInput('warning_on_retry').toLowerCase() === 'true';
var OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
var OUTPUT_EXIT_CODE_KEY = 'exit_code';
var OUTPUT_EXIT_ERROR_KEY = 'exit_error';
@@ -398,7 +399,12 @@ function runAction() {
throw error_1;
}
else {
core_1.warning("Attempt " + attempt + " failed. Reason: " + error_1.message);
if (WARNING_ON_RETRY) {
core_1.warning("Attempt " + attempt + " failed. Reason: " + error_1.message);
}
else {
core_1.info("Attempt " + attempt + " failed. Reason: " + error_1.message);
}
}
return [3 /*break*/, 6];
case 6:

View File

@@ -13,6 +13,7 @@ const COMMAND = getInput('command', { required: true });
const RETRY_WAIT_SECONDS = getInputNumber('retry_wait_seconds', false) || 10;
const POLLING_INTERVAL_SECONDS = getInputNumber('polling_interval_seconds', false) || 1;
const RETRY_ON = getInput('retry_on') || 'any';
const WARNING_ON_RETRY = getInput('warning_on_retry').toLowerCase() === 'true';
const OUTPUT_TOTAL_ATTEMPTS_KEY = 'total_attempts';
const OUTPUT_EXIT_CODE_KEY = 'exit_code';
@@ -130,7 +131,11 @@ async function runAction() {
// error: error
throw error;
} else {
warning(`Attempt ${attempt} failed. Reason: ${error.message}`);
if (WARNING_ON_RETRY) {
warning(`Attempt ${attempt} failed. Reason: ${error.message}`);
} else {
info(`Attempt ${attempt} failed. Reason: ${error.message}`);
}
}
}
}