From 0ce8384e73b5d0aadd3a2a37db78347037e57eb8 Mon Sep 17 00:00:00 2001 From: Mike Penz Date: Sun, 26 Feb 2023 12:13:36 +0000 Subject: [PATCH] - add additional logs on handling of configs (e.g. identify which config was picked) - outline if no config was picked and defaults are used --- src/main.ts | 10 ++++++++++ src/utils.ts | 12 +++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7811ce12..c62894f2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,10 +20,20 @@ async function run(): Promise { }) if (configurationJson) { configJson = parseConfiguration(configurationJson) + if (configJson) { + core.info(`ℹ️ Retreived configuration via 'configurationJson'.`) + } } // read in the configuration from the file if possible const configurationFile: string = core.getInput('configuration') const configFile = resolveConfiguration(repositoryPath, configurationFile) + if (configFile) { + core.info(`ℹ️ Retreived configuration via 'configuration' (via file).`) + } + + if (!configurationFile && !configFile) { + core.info(`ℹ️ No configuration provided. Using Defaults.`) + } // merge configs, use default values from DefaultConfig on missing definition const configuration = mergeConfiguration(configJson, configFile) diff --git a/src/utils.ts b/src/utils.ts index af751519..d261dae4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -35,23 +35,25 @@ export function failOrError(message: string | Error, failOnError: boolean): void /** * Retrieves the configuration given the file path, if not found it will fallback to the `DefaultConfiguration` */ -export function resolveConfiguration(githubWorkspacePath: string, configurationFile: string): Configuration { - let configuration = DefaultConfiguration +export function resolveConfiguration(githubWorkspacePath: string, configurationFile: string): Configuration | undefined { if (configurationFile) { const configurationPath = path.resolve(githubWorkspacePath, configurationFile) core.debug(`configurationPath = '${configurationPath}'`) const providedConfiguration = readConfiguration(configurationPath) if (providedConfiguration) { - configuration = providedConfiguration + const configuration = providedConfiguration core.info(`ℹ️ Configuration successfully loaded.`) if (core.isDebug()) { core.debug(`configuration = ${JSON.stringify(configuration)}`) } + return configuration + } else { + core.debug(`Configuration file could not be read.`) } } else { - core.info(`ℹ️ Configuration not provided. Using Defaults.`) + core.debug(`Configuration file not provided.`) } - return configuration + return undefined } /**