Skip to content

Commit

Permalink
Include versions ref in report (#109)
Browse files Browse the repository at this point in the history
* Fix small typo

* Export version ref (ref seems to be a good name as it can be a SHA, tag, version in the same time)

* Update Src/PowerShell/load-used-actions.ps1

Co-authored-by: Rob Bos <[email protected]>

* Update Src/PowerShell/load-used-actions.ps1

Co-authored-by: Rob Bos <[email protected]>

* Move actionRef within workflows structure
That way it is a non breaking change for existing consumers

* Update Src/PowerShell/load-used-actions.ps1

* Also add actionRef to the new data item

---------

Co-authored-by: Rob Bos <[email protected]>
  • Loading branch information
sebastienvermeille and rajbos committed Jul 8, 2024
1 parent d8efdf1 commit f056c6e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Src/PowerShell/load-used-actions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ function GetActionsFromWorkflow {
$uses=$step.Item("uses")
if ($null -ne $uses) {
Write-Host " Found action used: [$uses]"
$actionLink = $uses.Split("@")[0]
$splitted = $uses.Split("@")
$actionLink = $splitted[0]
$actionRef = $splitted[1]

$data = [PSCustomObject]@{
actionLink = $actionLink
actionRef = $actionRef
workflowFileName = $workflowFileName
repo = $repo
type = "action"
Expand All @@ -63,10 +66,13 @@ function GetActionsFromWorkflow {
$uses = $job.Value.Item("uses")
if ($null -ne $uses) {
Write-Host " Found reusable workflow used: [$uses]"
$actionLink = $uses.Split("@")[0]
$splitted = $uses.Split("@")
$actionLink = $splitted[0]
$actionRef = $splitted[1]

$data = [PSCustomObject]@{
actionLink = $actionLink
actionRef = $actionRef
workflowFileName = $workflowFileName
repo = $repo
type = "reusable workflow"
Expand Down Expand Up @@ -114,7 +120,7 @@ function GetAllUsedActionsFromRepo {
return;
}

# create hastable to store the results in
# create hashtable to store the results in
$actionsInRepo = @()

Write-Host "Found [$($workflowFiles.Length)] files in the workflows directory"
Expand Down Expand Up @@ -147,12 +153,13 @@ function SummarizeActionsUsed {

$summarized = @()
foreach ($action in $actions) {
$found = $summarized | Where-Object { $_.actionLink -eq $action.actionLink -And $_.type -eq $action.type }
$found = $summarized | Where-Object { $_.actionLink -eq $action.actionLink -And $_.type -eq $action.type }
if ($null -ne $found) {
# item already found, add this info to it
$newInfo = [PSCustomObject]@{
repo = $action.repo
workflowFileName = $action.workflowFileName
actionRef = $action.actionRef
}

$found.workflows += $newInfo
Expand All @@ -168,6 +175,7 @@ function SummarizeActionsUsed {
[PSCustomObject]@{
repo = $action.repo
workflowFileName = $action.workflowFileName
actionRef = $action.actionRef
}
)
}
Expand Down

0 comments on commit f056c6e

Please sign in to comment.