@@ -29,7 +29,10 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
2929 for _ , step := range job .Steps {
3030 if len (step .Uses ) > 0 {
3131 localUpdated := false
32- out , localUpdated = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap )
32+ out , localUpdated , err = PinAction (step .Uses , out , exemptedActions , pinToImmutable , actionCommitMap )
33+ if err != nil {
34+ return out , updated , err
35+ }
3336 updated = updated || localUpdated
3437 }
3538 }
@@ -38,22 +41,22 @@ func PinActions(inputYaml string, exemptedActions []string, pinToImmutable bool,
3841 return out , updated , nil
3942}
4043
41- func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool ) {
44+ func PinAction (action , inputYaml string , exemptedActions []string , pinToImmutable bool , actionCommitMap map [string ]string ) (string , bool , error ) {
4245
4346 updated := false
4447 if ! strings .Contains (action , "@" ) || strings .HasPrefix (action , "docker://" ) {
45- return inputYaml , updated // Cannot pin local actions and docker actions
48+ return inputYaml , updated , nil // Cannot pin local actions and docker actions
4649 }
4750
4851 if isAbsolute (action ) || (pinToImmutable && IsImmutableAction (action )) {
49- return inputYaml , updated
52+ return inputYaml , updated , nil
5053 }
5154 leftOfAt := strings .Split (action , "@" )
5255 tagOrBranch := leftOfAt [1 ]
5356
5457 // skip pinning for exempted actions
5558 if ActionExists (leftOfAt [0 ], exemptedActions ) {
56- return inputYaml , updated
59+ return inputYaml , updated , nil
5760 }
5861
5962 splitOnSlash := strings .Split (leftOfAt [0 ], "/" )
@@ -81,7 +84,7 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
8184 if ! semanticTagRegex .MatchString (tagOrBranch ) {
8285 tagOrBranch , err = getSemanticVersion (client , owner , repo , tagOrBranch , commitSHA )
8386 if err != nil {
84- return inputYaml , updated
87+ return inputYaml , updated , err
8588 }
8689 }
8790 break
@@ -92,11 +95,11 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
9295 if commitSHA == "" {
9396 commitSHA , _ , err = client .Repositories .GetCommitSHA1 (ctx , owner , repo , tagOrBranch , "" )
9497 if err != nil {
95- return inputYaml , updated
98+ return inputYaml , updated , err
9699 }
97100 tagOrBranch , err = getSemanticVersion (client , owner , repo , tagOrBranch , commitSHA )
98101 if err != nil {
99- return inputYaml , updated
102+ return inputYaml , updated , err
100103 }
101104
102105 }
@@ -130,7 +133,7 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
130133 inputYaml = actionRegex .ReplaceAllString (inputYaml , pinnedActionWithVersion + "$2" )
131134
132135 inputYaml , _ = removePreviousActionComments (pinnedActionWithVersion , inputYaml )
133- return inputYaml , ! strings .EqualFold (action , pinnedActionWithVersion )
136+ return inputYaml , ! strings .EqualFold (action , pinnedActionWithVersion ), nil
134137 }
135138
136139 updated = ! strings .EqualFold (action , fullPinned )
@@ -162,7 +165,7 @@ func PinAction(action, inputYaml string, exemptedActions []string, pinToImmutabl
162165 )
163166 inputYaml , _ = removePreviousActionComments (fullPinned , inputYaml )
164167
165- return inputYaml , updated
168+ return inputYaml , updated , nil
166169}
167170
168171// It may be that there was already a comment next to the action
0 commit comments