-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsettings.ts
26 lines (24 loc) · 889 Bytes
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as core from '@actions/core'
import * as io from '@actions/io'
export interface Settings {
// Path to git executable
gitPath: string
// Regex to select git tags used as boundaries for the changelog
tagRegex: RegExp
// Regex to filter out commit messages from the changelog
filterRegex: RegExp
// Destination file of the generated changelog
changelogFilePath: string
}
export async function initSettings(): Promise<Settings> {
const settings = {} as Settings
settings.gitPath = await io.which('git', true)
let regexFlag = ''
if (core.getInput('case-insensitive-regex') === 'true') {
regexFlag = 'i'
}
settings.tagRegex = RegExp(core.getInput('tag-regex'), regexFlag)
settings.filterRegex = RegExp(core.getInput('filter-regex'), regexFlag)
settings.changelogFilePath = core.getInput('changelog-file-path') || 'CHANGELOG.md'
return settings
}