- add additional logs on handling of configs (e.g. identify which config was picked) - outline if no config was picked and defaults are used
This commit is contained in:
+10
@@ -20,10 +20,20 @@ async function run(): Promise<void> {
|
||||
})
|
||||
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)
|
||||
|
||||
+7
-5
@@ -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
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user