@@ -134,6 +134,7 @@ async function checkActionsArePinned() {
134134 const usesRegex = / ^ \+ ? * u s e s : / ;
135135 const usesActionRegex =
136136 / ^ \+ ? * u s e s : * (?< user > [ ^ \/ ] + ) \/ (?< action > [ ^ @ ] + ) @ (?< ref > [ ^ ] * ) / ;
137+ const usesLocalRegex = / ^ \+ ? * u s e s : * \. \/ / ; // e.g. 'uses: ./.github/actions/something'
137138 const shaRegex = / ^ [ a - f 0 - 9 ] { 40 } $ / ;
138139 const whitelistedUsers = [ "getsentry" , "actions" ] ;
139140
@@ -142,7 +143,8 @@ async function checkActionsArePinned() {
142143 for ( const chunk of diff . chunks ) {
143144 for ( const change of chunk . changes ) {
144145 if ( change . add ) {
145- const match = change . content . match ( usesActionRegex ) ;
146+ const line = change . content ;
147+ const match = line . match ( usesActionRegex ) ;
146148 // Example of `match.groups`:
147149 // [Object: null prototype] {
148150 // user: 'getsentry',
@@ -151,21 +153,15 @@ async function checkActionsArePinned() {
151153 // }
152154 if ( match && match . groups ) {
153155 if ( ! match . groups . ref . match ( shaRegex ) ) {
154- if ( whitelistedUsers . includes ( match . groups . user ) ) {
155- message (
156- "Consider pinning the action by specifying a commit SHA instead of a tag/branch." ,
157- path ,
158- change . ln
159- ) ;
160- } else {
156+ if ( ! whitelistedUsers . includes ( match . groups . user ) ) {
161157 fail (
162158 "Please pin the action by specifying a commit SHA instead of a tag/branch." ,
163159 path ,
164160 change . ln
165161 ) ;
166162 }
167163 }
168- } else if ( change . content . match ( usesRegex ) ) {
164+ } else if ( line . match ( usesRegex ) && ! line . match ( usesLocalRegex ) ) {
169165 warn (
170166 "Couldn't parse 'uses:' declaration while checking for action pinning." ,
171167 path ,
0 commit comments