@@ -17,15 +17,25 @@ import (
1717func PinActions (inputYaml string , exemptedActions []string , pinToImmutable bool ) (string , bool , error ) {
1818 workflow := metadata.Workflow {}
1919 updated := false
20+ var allActions []string
2021 err := yaml .Unmarshal ([]byte (inputYaml ), & workflow )
2122 if err != nil {
2223 return inputYaml , updated , fmt .Errorf ("unable to parse yaml %v" , err )
2324 }
2425
2526 out := inputYaml
2627
28+ // get all jobs present in the workflow
29+ for _ , job := range workflow .Jobs {
30+ for _ , step := range job .Steps {
31+ if strings .Contains (step .Uses , "@" ) && ! strings .HasPrefix (step .Uses , "docker://" ) && ! isAbsolute (step .Uses ) {
32+ allActions = append (allActions , step .Uses )
33+ }
34+ }
35+ }
36+
2737 // get immutable map for the semantic versions of the actions present in the workflow
28- immutableMap := getSemanticActionsImmutableMap ( workflow , pinToImmutable )
38+ immutableMap := GetSemanticActionsImmutableMap ( allActions , pinToImmutable )
2939
3040 for _ , job := range workflow .Jobs {
3141
@@ -217,8 +227,7 @@ func ActionExists(actionName string, patterns []string) bool {
217227 return false
218228}
219229
220- func getSemanticActionsImmutableMap (workflow metadata.Workflow , pinToImmutable bool ) map [string ]bool {
221- var allActions []string
230+ func GetSemanticActionsImmutableMap (allActions []string , pinToImmutable bool ) map [string ]bool {
222231 var allSemanticActions []string
223232 immutableMap := make (map [string ]bool )
224233
@@ -227,15 +236,6 @@ func getSemanticActionsImmutableMap(workflow metadata.Workflow, pinToImmutable b
227236 return immutableMap
228237 }
229238
230- // get all jobs present in the workflow
231- for _ , job := range workflow .Jobs {
232- for _ , step := range job .Steps {
233- if strings .Contains (step .Uses , "@" ) && ! strings .HasPrefix (step .Uses , "docker://" ) && ! isAbsolute (step .Uses ) {
234- allActions = append (allActions , step .Uses )
235- }
236- }
237- }
238-
239239 PAT := os .Getenv ("PAT" )
240240
241241 ctx := context .Background ()
0 commit comments