Skip to content

Commit 7359c8b

Browse files
authored
Merge pull request #32 from samsmithnz/MinorEditsToMatchLeadTimeForChangesImprovements
Minor edits to match lead time for changes improvements
2 parents 6e7279f + dc9ccd6 commit 7359c8b

File tree

3 files changed

+30
-44
lines changed

3 files changed

+30
-44
lines changed

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,13 @@ Deployment frequency over last 30 days, is 1.2 per day, with a DORA rating of 'E
8888
```
8989

9090
In the job summary, we show a badge with details:
91-
> ![Deployment Frequency](https://img.shields.io/badge/frequency-4.67%20times%20per%20week-green?logo=github&label=Deployment%20frequency)
92-
>
93-
> **Definition:** For the primary application or service, how often is it successfully deployed to production.
94-
>
95-
> **Results:** Deployment frequency is **4.67 times per week** with a **High** rating, over the last **30 days**.
96-
>
97-
> **Details**:
98-
> - Repository: samsmithnz/deployment-frequency using main branch
99-
> - Workflow(s) used: CI
100-
> - Active days of deployment: 13 days
101-
> ---
91+
92+
---
93+
![Deployment Frequency](https://img.shields.io/badge/frequency-4.67%20times%20per%20week-green?logo=github&label=Deployment%20frequency)<br>
94+
**Definition:** For the primary application or service, how often is it successfully deployed to production.<br>
95+
**Results:** Deployment frequency is **4.67 times per week** with a **High** rating, over the last **30 days**.<br>
96+
**Details**:<br>
97+
- Repository: samsmithnz/deployment-frequency using main branch
98+
- Workflow(s) used: CI
99+
- Active days of deployment: 13 days
100+
---

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ runs:
3838
shell: pwsh
3939
run: |
4040
$result = ${{ github.action_path }}/src/deploymentfrequency.ps1 -ownerRepo "${{ inputs.owner-repo }}" -workflows "${{ inputs.workflows }}" -branch "${{ inputs.default-branch }}" -numberOfDays ${{ inputs.number-of-days }} -patToken "${{ inputs.pat-token }}" -actionsToken "${{ inputs.actions-token }}" -appId "${{ inputs.app-id }}" -appInstallationId "${{ inputs.app-install-id }}" -appPrivateKey "${{ inputs.app-private-key }}"
41-
Write-Host "::set-output name=result::$result"
41+
#Write-Host "::set-output name=result::$result"
4242
Write-Output $result >> $env:GITHUB_STEP_SUMMARY
4343

src/deploymentfrequency.ps1

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -169,71 +169,58 @@ function Main ([string] $ownerRepo,
169169
$everySixMonthsDeployment = 1 / (6 * 30) #Every 6 months
170170
$yearlyDeployment = 1 / 365
171171

172-
#Calculate rating
173-
$rating = ""
174-
$color = ""
175-
172+
#Calculate rating, metric, and unit
176173
if ($deploymentsPerDay -le 0)
177174
{
178175
$rating = "None"
179-
$color = "grey"
176+
$color = "lightgrey"
177+
$displayMetric = 0
178+
$displayUnit = "per day"
180179
}
181-
elseif ($deploymentsPerDay -ge $dailyDeployment)
180+
elseif ($deploymentsPerDay -gt $dailyDeployment)
182181
{
183182
$rating = "Elite"
184183
$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-
{
205184
$displayMetric = [math]::Round($deploymentsPerDay,2)
206185
$displayUnit = "per day"
207186
}
208187
elseif ($deploymentsPerDay -le $dailyDeployment -and $deploymentsPerDay -ge $weeklyDeployment)
209188
{
189+
$rating = "High"
190+
$color = "green"
210191
$displayMetric = [math]::Round($deploymentsPerDay * 7,2)
211192
$displayUnit = "times per week"
212193
}
213194
elseif ($deploymentsPerDay -lt $weeklyDeployment -and $deploymentsPerDay -ge $monthlyDeployment)
214195
{
196+
$rating = "Medium"
197+
$color = "yellow"
215198
$displayMetric = [math]::Round($deploymentsPerDay * 30,2)
216199
$displayUnit = "times per month"
217200
}
218201
elseif ($deploymentsPerDay -lt $monthlyDeployment -and $deploymentsPerDay -gt $yearlyDeployment)
219202
{
203+
$rating = "Low"
204+
$color = "red"
220205
$displayMetric = [math]::Round($deploymentsPerDay * 30,2)
221206
$displayUnit = "times per month"
222207
}
223208
elseif ($deploymentsPerDay -le $yearlyDeployment)
224209
{
210+
$rating = "Low"
211+
$color = "red"
225212
$displayMetric = [math]::Round($deploymentsPerDay * 365,2)
226213
$displayUnit = "times per year"
227214
}
228215

229216
if ($dateList.Count -gt 0 -and $numberOfDays -gt 0)
230217
{
231218
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
233220
}
234221
else
235222
{
236-
return Format-NoOutputMarkdown -workflows $workflows -numberOfDays $numberOfDays
223+
return GetFormattedMarkdownForNoResult -workflows $workflows -numberOfDays $numberOfDays
237224
}
238225
}
239226

@@ -335,11 +322,11 @@ function Get-JwtToken([string] $appId, [string] $appInstallationId, [string] $ap
335322
}
336323

337324
# 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)
339326
{
340-
$encodedDeploymentFrequency = [uri]::EscapeUriString($displayMetric + " " + $displayUnit)
327+
$encodedString = [uri]::EscapeUriString($displayMetric + " " + $displayUnit)
341328
#double newline to start the line helps with formatting in GitHub logs
342-
$markdown = "`n`n![Deployment Frequency](https://img.shields.io/badge/frequency-" + $encodedDeploymentFrequency + "-" + $color + "?logo=github&label=Deployment%20frequency)`n" +
329+
$markdown = "`n`n![Deployment Frequency](https://img.shields.io/badge/frequency-" + $encodedString + "-" + $color + "?logo=github&label=Deployment%20frequency)`n" +
343330
"**Definition:** For the primary application or service, how often is it successfully deployed to production.`n" +
344331
"**Results:** Deployment frequency is **$displayMetric $displayUnit** with a **$rating** rating, over the last **$numberOfDays days**.`n" +
345332
"**Details**:`n" +
@@ -350,7 +337,7 @@ function Format-OutputMarkdown([array] $workflowNames, [string] $rating, [string
350337
return $markdown
351338
}
352339

353-
function Format-NoOutputMarkdown([string] $workflows, [string] $numberOfDays)
340+
function GetFormattedMarkdownForNoResult([string] $workflows, [string] $numberOfDays)
354341
{
355342
#double newline to start the line helps with formatting in GitHub logs
356343
$markdown = "`n`n![Deployment Frequency](https://img.shields.io/badge/frequency-none-lightgrey?logo=github&label=Deployment%20frequency)`n`n" +

0 commit comments

Comments
 (0)