-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.ps1
60 lines (46 loc) · 1.76 KB
/
action.ps1
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
50
51
52
53
54
55
56
57
58
59
60
# Copyright (c) 2023 Matthias Wolf, Mawosoft.
#Requires -Version 7.2 # Required by ListPackageHelper
using namespace System
[CmdletBinding()]
param(
[Parameter(Mandatory, Position = 0)]
[ValidateNotNullOrEmpty()]
[string]$InputsJson
)
Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'
class Inputs {
hidden [hashtable]$_inputs
Inputs([string]$json) {
$ht = ConvertFrom-Json -InputObject $json -AsHashtable -NoEnumerate
$this._inputs = [hashtable]::new($ht, [StringComparer]::OrdinalIgnoreCase)
}
[string] GetString([string]$key) {
return "$($this._inputs[$key])".Trim()
}
[string[]] GetArray([string]$key) {
return "$($this._inputs[$key])".Split([char]"`n", [StringSplitOptions]::TrimEntries -bor [StringSplitOptions]::RemoveEmptyEntries)
}
[bool] GetBool([string]$key) {
return "$($this._inputs[$key])".Trim() -eq 'true'
}
[int] GetInt([string]$key) {
return $this._inputs[$key]
}
}
$inputs = [Inputs]::new($InputsJson)
$workingdir = $inputs.GetString('working-directory')
if ($workingdir) {
Set-Location -LiteralPath $workingdir
}
$params = @{
GitHubToken = ConvertTo-SecureString -String $inputs.GetString('token') -AsPlainText
Projects = $inputs.GetArray('projects')
NoRestore = $inputs.GetBool('no-restore')
NuGetConfig = $inputs.GetString('nuget-config')
NuGetSources = $inputs.GetArray('nuget-sources')
IncludeOutdatedTransitive = $inputs.GetBool('include-outdated-transitive')
ArtifactName = $inputs.GetString('artifact-name')
IssueLabels = $inputs.GetArray('issue-labels')
}
& "$PSScriptRoot/src/checkDependencies.ps1" @params