-
Notifications
You must be signed in to change notification settings - Fork 11
/
config.js
49 lines (40 loc) · 1.96 KB
/
config.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const core = require('@actions/core')
const github = require('@actions/github')
// Gets all the required inputs and validates them before proceeding.
function getConfig() {
const mode = core.getInput('mode', { required: true }).toLowerCase()
if (mode !== 'validate' && mode !== 'bump') {
throw new Error("mode must be either 'validate' or 'bump'")
}
const token = core.getInput('repo-token', { required: true })
core.setSecret(token)
const releaseNotesPrefix = core.getInput('release-notes-prefix')
const releaseNotesSuffix = core.getInput('release-notes-suffix')
let releaseNotesPrefixPattern
if (releaseNotesPrefix !== undefined && releaseNotesPrefix !== '') {
releaseNotesPrefixPattern = new RegExp(releaseNotesPrefix)
}
let releaseNotesSuffixPattern
if (releaseNotesSuffix !== undefined && releaseNotesSuffix !== '') {
releaseNotesSuffixPattern = new RegExp(releaseNotesSuffix)
}
const releaseLabels = {}
releaseLabels[core.getInput('major-label') || 'major release'] = 'major'
releaseLabels[core.getInput('minor-label') || 'minor release'] = 'minor'
releaseLabels[core.getInput('patch-label') || 'patch release'] = 'patch'
const noopLabels = { }
const configuredNoopLabels = core.getMultilineInput('noop-labels', { trimWhitespace: true })
for (let i = 0; i < configuredNoopLabels.length; i++) noopLabels[configuredNoopLabels[i]] = 'skip'
return {
mode: mode,
octokit: github.getOctokit(token),
releaseLabels: releaseLabels,
noopLabels: noopLabels,
releaseNotesPrefixPattern: releaseNotesPrefixPattern,
releaseNotesSuffixPattern: releaseNotesSuffixPattern,
requireReleaseNotes: core.getInput('require-release-notes').toLowerCase() === 'true',
baseBranch: core.getInput('base-branch').toLowerCase() === 'true',
v: core.getInput('with-v').toLowerCase() === 'true' ? 'v' : '',
}
}
exports.getConfig = getConfig