Read a hardcoded config file.

This commit is contained in:
Federico Builes
2022-09-16 14:30:57 +02:00
parent 7e2a489d03
commit 8ef181b2cb

View File

@@ -1,7 +1,12 @@
import * as fs from 'fs'
import path from 'path'
import YAML from 'yaml'
import * as core from '@actions/core'
import * as z from 'zod'
import {ConfigurationOptions, SEVERITIES} from './schemas'
export const CONFIG_FILEPATH = './.github/dependency-review.yml'
function getOptionalInput(name: string): string | undefined {
const value = core.getInput(name)
return value.length > 0 ? value : undefined
@@ -30,3 +35,17 @@ export function readConfig(): ConfigurationOptions {
head_ref
}
}
export function readConfigFile(
filePath: string = CONFIG_FILEPATH
): ConfigurationOptions {
let data
try {
data = fs.readFileSync(path.resolve(filePath), 'utf-8')
} catch (error: unknown) {
throw error
}
const values = YAML.parse(data)
return values
}