@@ -44,16 +44,36 @@ function GetActionsFromWorkflow {
44
44
foreach ($job in $parsedYaml [" jobs" ].GetEnumerator()) {
45
45
Write-Host " Job found: [$ ( $job.Key ) ]"
46
46
$steps = $job.Value.Item (" steps" )
47
- foreach ($step in $steps ) {
48
- $uses = $step.Item (" uses" )
47
+ if ($null -ne $steps ) {
48
+ foreach ($step in $steps ) {
49
+ $uses = $step.Item (" uses" )
50
+ if ($null -ne $uses ) {
51
+ Write-Host " Found action used: [$uses ]"
52
+ $actionLink = $uses.Split (" @" )[0 ]
53
+
54
+ $data = [PSCustomObject ]@ {
55
+ actionLink = $actionLink
56
+ workflowFileName = $workflowFileName
57
+ repo = $repo
58
+ type = " action"
59
+ }
60
+
61
+ $actions += $data
62
+ }
63
+ }
64
+ }
65
+ else {
66
+ # check for reusable workflow
67
+ $uses = $job.Value.Item (" uses" )
49
68
if ($null -ne $uses ) {
50
- Write-Host " Found action used: [$uses ]"
69
+ Write-Host " Found reusable workflow used: [$uses ]"
51
70
$actionLink = $uses.Split (" @" )[0 ]
52
71
53
72
$data = [PSCustomObject ]@ {
54
73
actionLink = $actionLink
55
74
workflowFileName = $workflowFileName
56
75
repo = $repo
76
+ type = " reusable workflow"
57
77
}
58
78
59
79
$actions += $data
@@ -93,7 +113,7 @@ function GetAllUsedActionsFromRepo {
93
113
}
94
114
catch {
95
115
Write-Warning " Error handling this workflow file:"
96
- Write-Host $workflowFile | ConvertFrom-Json - Depth 10
116
+ Write-Host $workflowFile.Replace ( $PAT , " **** " ) | ConvertFrom-Json - Depth 10
97
117
Write-Warning " ----------------------------------"
98
118
Write-Host " Error: [$_ ]"
99
119
Write-Warning " ----------------------------------"
@@ -110,9 +130,9 @@ function SummarizeActionsUsed {
110
130
111
131
$summarized = @ ()
112
132
foreach ($action in $actions ) {
113
- $found = $summarized | Where-Object { $_.actionLink -eq $action.actionLink }
133
+ $found = $summarized | Where-Object { $_.actionLink -eq $action.actionLink -And $_ .type -eq $action .type }
114
134
if ($null -ne $found ) {
115
- # action already found, add this info to it
135
+ # item already found, add this info to it
116
136
$newInfo = [PSCustomObject ]@ {
117
137
repo = $action.repo
118
138
workflowFileName = $action.workflowFileName
@@ -122,16 +142,17 @@ function SummarizeActionsUsed {
122
142
$found.count ++
123
143
}
124
144
else {
125
- # new action , create a new object
145
+ # new item , create a new object
126
146
$newItem = [PSCustomObject ]@ {
147
+ type = $action.type
127
148
actionLink = $action.actionLink
128
149
count = 1
129
150
workflows = @ (
130
151
[PSCustomObject ]@ {
131
152
repo = $action.repo
132
153
workflowFileName = $action.workflowFileName
133
154
}
134
- )
155
+ )
135
156
}
136
157
$summarized += $newItem
137
158
}
@@ -150,7 +171,7 @@ function LoadAllUsedActionsFromRepos {
150
171
151
172
# create hastable
152
173
$actions = @ ()
153
- $i = 0
174
+ # $i=0
154
175
foreach ($repo in $repos ) {
155
176
if ($null -ne $repo -And $repo.full_name.Length -gt 0 ) {
156
177
Write-Host " Loading actions from repo: [$ ( $repo.full_name ) ]"
@@ -160,12 +181,12 @@ function LoadAllUsedActionsFromRepos {
160
181
161
182
# comment out code below to stop after a certain number of repos to prevent issues with
162
183
# rate limiting on the load file count (that is not workin correctly)
163
-
164
- # $i++
165
- # if ($i -eq 2) {
166
- # # break out on second result:
184
+ # $i++
185
+ # if ($i -eq 2) {
186
+ # # break on second result:
187
+ # Write-Host "Breaking after [$i] repos"
167
188
# return $actions
168
- # }
189
+ # }
169
190
}
170
191
}
171
192
0 commit comments