-
Notifications
You must be signed in to change notification settings - Fork 12
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
Showing
3 changed files
with
115 additions
and
24 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
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
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,21 +1,35 @@ | ||
import * as core from '@actions/core'; | ||
|
||
import { labelActions } from './github'; | ||
export interface args { | ||
dryrun: boolean; | ||
minimumUpvotesToExempt: number; | ||
token: string; | ||
expirationLabelMap?: string[]; | ||
updateRemoveLabels?: string[]; | ||
} | ||
|
||
export function getAndValidateInputs(): args { | ||
const minUpvotes = parseInt(core.getInput('minimumUpvotesToExempt', { required: false })); | ||
// Number inputs | ||
const minUpvotes = parseInt(core.getInput('minimum-upvotes-to-exempt', { required: false })); | ||
for (const numberInput of [minUpvotes]) { | ||
if (isNaN(numberInput)) { | ||
throw Error(`Input ${numberInput} did not parse to a valid integar`); | ||
throw Error(`Input ${numberInput} did not parse to a valid integer`); | ||
} | ||
} | ||
|
||
// Action map | ||
const labelValidationRegex = new RegExp(`^[A-Za-z0-9_.-,]+:(${labelActions.join('|')}):\\d+(:[A-Za-z0-9_.-,]+)?/i`); | ||
const expirationLabelMap = core | ||
.getMultilineInput('expiration-label-map', { required: false }) | ||
.filter(m => labelValidationRegex.test(m)); | ||
core.debug(`Parsed label mapping: ${expirationLabelMap}`); | ||
const updateRemoveLabels = core.getInput('update-remove-labels', { required: false }).split(','); | ||
|
||
return { | ||
dryrun: core.getBooleanInput('dryrun', { required: false }), | ||
dryrun: core.getBooleanInput('dry-run', { required: false }), | ||
minimumUpvotesToExempt: minUpvotes, | ||
token: process.env.REPO_TOKEN!, | ||
token: core.getInput('repo-token'), | ||
expirationLabelMap, | ||
updateRemoveLabels, | ||
}; | ||
} |