2024-01-22 21:46:12 -05:00
|
|
|
import * as core from '@actions/core'
|
|
|
|
import {Inputs} from './constants'
|
|
|
|
import {MergeInputs} from './merge-inputs'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper to get all the inputs for the action
|
|
|
|
*/
|
|
|
|
export function getInputs(): MergeInputs {
|
|
|
|
const name = core.getInput(Inputs.Name, {required: true})
|
|
|
|
const pattern = core.getInput(Inputs.Pattern, {required: true})
|
|
|
|
const separateDirectories = core.getBooleanInput(Inputs.SeparateDirectories)
|
|
|
|
const deleteMerged = core.getBooleanInput(Inputs.DeleteMerged)
|
2024-08-15 20:29:20 -04:00
|
|
|
const includeGitDirectory = core.getBooleanInput(Inputs.IncludeGitDirectory)
|
2024-01-22 21:46:12 -05:00
|
|
|
|
|
|
|
const inputs = {
|
|
|
|
name,
|
|
|
|
pattern,
|
|
|
|
separateDirectories,
|
|
|
|
deleteMerged,
|
|
|
|
retentionDays: 0,
|
2024-08-15 20:29:20 -04:00
|
|
|
compressionLevel: 6,
|
|
|
|
includeGitDirectory
|
2024-01-22 21:46:12 -05:00
|
|
|
} as MergeInputs
|
|
|
|
|
|
|
|
const retentionDaysStr = core.getInput(Inputs.RetentionDays)
|
|
|
|
if (retentionDaysStr) {
|
|
|
|
inputs.retentionDays = parseInt(retentionDaysStr)
|
|
|
|
if (isNaN(inputs.retentionDays)) {
|
|
|
|
core.setFailed('Invalid retention-days')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const compressionLevelStr = core.getInput(Inputs.CompressionLevel)
|
|
|
|
if (compressionLevelStr) {
|
|
|
|
inputs.compressionLevel = parseInt(compressionLevelStr)
|
|
|
|
if (isNaN(inputs.compressionLevel)) {
|
|
|
|
core.setFailed('Invalid compression-level')
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inputs.compressionLevel < 0 || inputs.compressionLevel > 9) {
|
|
|
|
core.setFailed('Invalid compression-level. Valid values are 0-9')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return inputs
|
|
|
|
}
|