mirror of
https://code.forgejo.org/actions/upload-artifact
synced 2025-06-12 14:14:10 +02:00
add merge artifact sub-action
This commit is contained in:
parent
52899c8c02
commit
997fffa355
11 changed files with 1100 additions and 61 deletions
44
src/merge/input-helper.ts
Normal file
44
src/merge/input-helper.ts
Normal file
|
@ -0,0 +1,44 @@
|
|||
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)
|
||||
|
||||
const inputs = {
|
||||
name,
|
||||
pattern,
|
||||
separateDirectories,
|
||||
deleteMerged,
|
||||
retentionDays: 0,
|
||||
compressionLevel: 6
|
||||
} 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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue