-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathParameters.psd1
More file actions
244 lines (213 loc) · 7.96 KB
/
Parameters.psd1
File metadata and controls
244 lines (213 loc) · 7.96 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
@{
Parameters = @(
@{
Name = 'relative_folder_path'
Type = 'String[]'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified, but warn that it will
# inspect the entire repository:
$Message = @(
'No relative folder path specified;'
'defaulting to search the entire working directory for stale content.'
) -join ' '
Write-Warning -Message $Message
}
Process = {
param($Parameters, $Value, $ErrorTarget)
$RelativeFolderPath = $Value -split "`n"
| ForEach-Object -Process { $_.Trim().Trim('"').Trim("'") }
| Where-Object -FilterScript { -not [string]::IsNullOrEmpty($_) }
if ([string]::IsNullOrEmpty($RelativeFolderPath)) {
$Parameters.RelativeFolderPath = '.'
} else {
$Parameters.RelativeFolderPath = $RelativeFolderPath
}
Write-HostParameter -Name RelativeFolderPath -Value $Parameters.RelativeFolderPath
return $Parameters
}
}
@{
Name = 'exclude_folder_segment'
Type = 'String[]'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
$ExcludeFolderSegment = $Value -split "`n"
| ForEach-Object -Process { $_.Trim().Trim('"').Trim("'") }
| Where-Object -FilterScript { -not [string]::IsNullOrEmpty($_) }
if (![string]::IsNullOrEmpty($ExcludeFolderSegment)) {
$Parameters.ExcludeFolderSegment = $ExcludeFolderSegment
Write-HostParameter -Name ExcludeFolderSegment -Value $Parameters.ExcludeFolderSegment
}
return $Parameters
}
}
@{
Name = 'days_until_stale'
Type = 'Int'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
if ([string]::IsNullOrEmpty($Value)) {
return $Parameters
}
# Because DaysUntilStale and StaleSinceDate belong to different
# parameter sets, do not add DaysUntilStale if StaleSinceDate is already
# defined.
if ($Parameters.ContainsKey('StaleSinceDate')) {
$Message = @(
'Specified both days_until_stale and stale_since_date parameters;'
'they cannot be used together. Using the stale_since_date value of'
"'$($Parameters.StaleSinceDate)' for the action. To use the"
'days_until_stale value, remove the stale_since_date input from'
'your workflow definition.'
) -join ' '
Write-Warning $Message
}
$Parameters.DaysUntilStale = [int]$Value
Write-HostParameter -Name DaysUntilStale -Value $Parameters.DaysUntilStale
return $Parameters
}
}
@{
Name = 'stale_since_date'
Type = 'DateTime'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
if ([string]::IsNullOrEmpty($Value)) {
return $Parameters
}
# Because DaysUntilStale and StaleSinceDate belong to different
# parameter sets, remove DaysUntilStale before adding StaleSinceDate.
if ($Parameters.ContainsKey('DaysUntilStale')) {
$Message = @(
'Specified both days_until_stale and stale_since_date parameters;'
'they cannot be used together. Using the stale_since_date value of'
"'$($Value)' for the action. To use the days_until_stale value,"
'remove the stale_since_date input from your workflow definition.'
) -join ' '
Write-Warning $Message
$Parameters.Remove('DaysUntilStale')
}
$Parameters.StaleSinceDate = [datetime]$Value
Write-HostParameter -Name StaleSinceDate -Value $Parameters.StaleSinceDate
return $Parameters
}
}
@{
Name = 'upload_artifact'
Type = 'Bool'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
if ([string]::IsNullOrEmpty($Value)) {
return $Parameters
}
if ($Parameters.ContainsKey('ExportAsCsv')) {
$Message = @(
'Specified both export_as_csv and upload_artifact parameters;'
'upload_artifact implies export_as_csv, so you do not need to'
'specify both. The stale content report will be exported as a'
'CSV and uploaded as an artifact in this action.'
) -join ' '
Write-Warning $Message
}
if ($Value -eq 'True') {
$Parameters.UploadArtifact = $true
Write-HostParameter -Name UploadArtifact -Value $Parameters.UploadArtifact
} else {
$Message = @(
"Specified upload_artifact as '$Value';"
'unless specified as "true" (case-insensitive), it is ignored and'
'the stale content report is not automatically uploaded as an'
'action artifact.'
) -join ' '
Write-Warning $Message
}
return $Parameters
}
}
@{
Name = 'export_as_csv'
Type = 'Bool'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
if ([string]::IsNullOrEmpty($Value)) {
return $Parameters
}
if ($Parameters.ContainsKey('UploadArtifact')) {
$Message = @(
'Specified both export_as_csv and upload_artifact parameters;'
'upload_artifact implies export_as_csv, so you do not need to'
'specify both. The stale content report will be exported as a'
'CSV and uploaded as an artifact in this action.'
) -join ' '
Write-Warning $Message
}
if ($Value -eq 'True') {
$Parameters.ExportAsCsv = $true
Write-HostParameter -Name ExportAsCsv -Value $Parameters.ExportAsCsv
} else {
$Message = @(
"Specified export_as_csv as '$Value';"
'unless specified as "true" (case-insensitive), it is ignored and'
'the stale content report is exported as a CSV file.'
) -join ' '
Write-Warning $Message
}
return $Parameters
}
}
@{
Name = 'export_path'
Type = 'string'
IfNullOrEmpty = {
param($ErrorTarget)
# It's okay if this parameter is not specified.
}
Process = {
param($Parameters, $Value, $ErrorTarget)
if ([string]::IsNullOrEmpty($Value)) {
return $Parameters
} elseif ($Value -match '\$\(.+\)') {
# It seems like they're trying to get a dynamic value for the name,
# which we can't support for security reasons. Instead, they should
# dynamically generate the name in a prior step.
$Message = @(
"Specified export_path as '$Value', which looks like a dynamically"
'defined value; this input is passed literally. For this run,'
'the default file name will be used instead.To dynamically generate'
'a value for the CSV file name, use another step in your workflow'
'to define the output and reference for this input instead. For an'
'example on how to do this, see our documentation.'
'Note that any value matching the following regex will trigger this'
"warning: '\$\(.+\)'"
) -join ' '
Write-Warning -Message $Message
} else {
$Parameters.ExportPath = $Value.Trim()
Write-HostParameter -Name ExportPath -Value $Parameters.ExportPath
}
return $Parameters
}
}
)
}