- introduce capability to define the Configuration via the build yml without the requirement of a file

- this also allows to generate changelogs without the need to chech-out
This commit is contained in:
Mike Penz
2022-07-29 09:21:44 +00:00
committed by GitHub
parent ffcbb8e311
commit 02b79cb00a
7 changed files with 130 additions and 28 deletions
+17 -9
View File
@@ -67,24 +67,32 @@ export function resolveConfiguration(
/**
* Reads in the configuration from the JSON file
*/
function readConfiguration(filename: string): Configuration | null {
let rawdata: string
function readConfiguration(filename: string): Configuration | undefined {
try {
rawdata = fs.readFileSync(filename, 'utf8')
const rawdata = fs.readFileSync(filename, 'utf8')
if (rawdata) {
return parseConfiguration(rawdata)
}
} catch (error) {
core.info(
`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`
)
return null
core.debug(`Failed to load configuration due to: ${error}`)
}
core.info(
`⚠️ Configuration provided, but it couldn't be found. Fallback to Defaults.`
)
return undefined
}
/**
* Parses the configuration from the JSON file
*/
export function parseConfiguration(config: string): Configuration | undefined {
try {
const configurationJSON: Configuration = JSON.parse(rawdata)
const configurationJSON: Configuration = JSON.parse(config)
return configurationJSON
} catch (error) {
core.info(
`⚠️ Configuration provided, but it couldn't be parsed. Fallback to Defaults.`
)
return null
return undefined
}
}