forked from Spatial-Quotient/pr-semver-bump
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dhruv
committed
Dec 14, 2023
1 parent
ae5b04b
commit f61fc1b
Showing
6 changed files
with
4,847 additions
and
5,237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,53 @@ | ||
const core = require("@actions/core"); | ||
const github = require("@actions/github"); | ||
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", | ||
useSSH: core.getInput("use-ssh").toLowerCase() === "true", | ||
v: core.getInput("with-v").toLowerCase() === "true" ? "v" : "", | ||
}; | ||
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', | ||
useSSH: core.getInput('use-ssh').toLowerCase() === 'true', | ||
v: core.getInput('with-v').toLowerCase() === 'true' ? 'v' : '', | ||
} | ||
} | ||
|
||
exports.getConfig = getConfig; | ||
exports.getConfig = getConfig |
Oops, something went wrong.