@@ -169,71 +169,58 @@ function Main ([string] $ownerRepo,
169
169
$everySixMonthsDeployment = 1 / (6 * 30 ) # Every 6 months
170
170
$yearlyDeployment = 1 / 365
171
171
172
- # Calculate rating
173
- $rating = " "
174
- $color = " "
175
-
172
+ # Calculate rating, metric, and unit
176
173
if ($deploymentsPerDay -le 0 )
177
174
{
178
175
$rating = " None"
179
- $color = " grey"
176
+ $color = " lightgrey"
177
+ $displayMetric = 0
178
+ $displayUnit = " per day"
180
179
}
181
- elseif ($deploymentsPerDay -ge $dailyDeployment )
180
+ elseif ($deploymentsPerDay -gt $dailyDeployment )
182
181
{
183
182
$rating = " Elite"
184
183
$color = " green"
185
- }
186
- elseif ($deploymentsPerDay -le $dailyDeployment -and $deploymentsPerDay -ge $monthlyDeployment )
187
- {
188
- $rating = " High"
189
- $color = " green"
190
- }
191
- elseif (deploymentsPerDay -le $monthlyDeployment -and $deploymentsPerDay -ge $everySixMonthsDeployment )
192
- {
193
- $rating = " Medium"
194
- $color = " yellow"
195
- }
196
- elseif ($deploymentsPerDay -le $everySixMonthsDeployment )
197
- {
198
- $rating = " Low"
199
- $color = " red"
200
- }
201
-
202
- # Calculate metric and unit
203
- if ($deploymentsPerDay -gt $dailyDeployment )
204
- {
205
184
$displayMetric = [math ]::Round($deploymentsPerDay , 2 )
206
185
$displayUnit = " per day"
207
186
}
208
187
elseif ($deploymentsPerDay -le $dailyDeployment -and $deploymentsPerDay -ge $weeklyDeployment )
209
188
{
189
+ $rating = " High"
190
+ $color = " green"
210
191
$displayMetric = [math ]::Round($deploymentsPerDay * 7 , 2 )
211
192
$displayUnit = " times per week"
212
193
}
213
194
elseif ($deploymentsPerDay -lt $weeklyDeployment -and $deploymentsPerDay -ge $monthlyDeployment )
214
195
{
196
+ $rating = " Medium"
197
+ $color = " yellow"
215
198
$displayMetric = [math ]::Round($deploymentsPerDay * 30 , 2 )
216
199
$displayUnit = " times per month"
217
200
}
218
201
elseif ($deploymentsPerDay -lt $monthlyDeployment -and $deploymentsPerDay -gt $yearlyDeployment )
219
202
{
203
+ $rating = " Low"
204
+ $color = " red"
220
205
$displayMetric = [math ]::Round($deploymentsPerDay * 30 , 2 )
221
206
$displayUnit = " times per month"
222
207
}
223
208
elseif ($deploymentsPerDay -le $yearlyDeployment )
224
209
{
210
+ $rating = " Low"
211
+ $color = " red"
225
212
$displayMetric = [math ]::Round($deploymentsPerDay * 365 , 2 )
226
213
$displayUnit = " times per year"
227
214
}
228
215
229
216
if ($dateList.Count -gt 0 -and $numberOfDays -gt 0 )
230
217
{
231
218
Write-Host " Deployment frequency over last $numberOfDays days, is $displayMetric $displayUnit , with a DORA rating of '$rating '"
232
- return Format-OutputMarkdown - workflowNames $workflowNames - displayMetric $displayMetric - displayUnit $displayUnit - repo $ownerRepo - branch $branch - numberOfDays $numberOfDays - numberOfUniqueDates $uniqueDates.Length.ToString () - color $color - rating $rating
219
+ return GetFormattedMarkdown - workflowNames $workflowNames - displayMetric $displayMetric - displayUnit $displayUnit - repo $ownerRepo - branch $branch - numberOfDays $numberOfDays - numberOfUniqueDates $uniqueDates.Length.ToString () - color $color - rating $rating
233
220
}
234
221
else
235
222
{
236
- return Format-NoOutputMarkdown - workflows $workflows - numberOfDays $numberOfDays
223
+ return GetFormattedMarkdownForNoResult - workflows $workflows - numberOfDays $numberOfDays
237
224
}
238
225
}
239
226
@@ -335,11 +322,11 @@ function Get-JwtToken([string] $appId, [string] $appInstallationId, [string] $ap
335
322
}
336
323
337
324
# Format output for deployment frequency in markdown
338
- function Format-OutputMarkdown ([array ] $workflowNames , [string ] $rating , [string ] $displayMetric , [string ] $displayUnit , [string ] $repo , [string ] $branch , [string ] $numberOfDays , [string ] $numberOfUniqueDates , [string ] $color )
325
+ function GetFormattedMarkdown ([array ] $workflowNames , [string ] $rating , [string ] $displayMetric , [string ] $displayUnit , [string ] $repo , [string ] $branch , [string ] $numberOfDays , [string ] $numberOfUniqueDates , [string ] $color )
339
326
{
340
- $encodedDeploymentFrequency = [uri ]::EscapeUriString($displayMetric + " " + $displayUnit )
327
+ $encodedString = [uri ]::EscapeUriString($displayMetric + " " + $displayUnit )
341
328
# double newline to start the line helps with formatting in GitHub logs
342
- $markdown = " `n`n `n " +
329
+ $markdown = " `n`n `n " +
343
330
" **Definition:** For the primary application or service, how often is it successfully deployed to production.`n " +
344
331
" **Results:** Deployment frequency is **$displayMetric $displayUnit ** with a **$rating ** rating, over the last **$numberOfDays days**.`n " +
345
332
" **Details**:`n " +
@@ -350,7 +337,7 @@ function Format-OutputMarkdown([array] $workflowNames, [string] $rating, [string
350
337
return $markdown
351
338
}
352
339
353
- function Format-NoOutputMarkdown ([string ] $workflows , [string ] $numberOfDays )
340
+ function GetFormattedMarkdownForNoResult ([string ] $workflows , [string ] $numberOfDays )
354
341
{
355
342
# double newline to start the line helps with formatting in GitHub logs
356
343
$markdown = " `n`n `n`n " +
0 commit comments