@@ -779,23 +779,67 @@ ${content}`;
779
779
CI_COMMIT_SHA ,
780
780
"getAssetName"
781
781
) ;
782
- var matches = regExp . exec ( fileContents ) ;
782
+ const startRegex =
783
+ / { { \s * c o n f i g \s * \( / im;
784
+ const startMatch = fileContent . match ( startRegex ) ;
785
+ let configSection = ''
786
+ if ( startMatch ) {
787
+ const startIndex = startMatch . index ;
788
+ const openParensIndex = fileContent . indexOf ( '(' , startIndex ) + 1 ;
789
+ let openParensCount = 1 ;
790
+ let endIndex = openParensIndex ;
791
+
792
+ while ( openParensCount > 0 && endIndex < fileContent . length ) {
793
+ const char = fileContent [ endIndex ] ;
794
+
795
+ if ( char === '(' ) {
796
+ openParensCount ++ ;
797
+ } else if ( char === ')' ) {
798
+ openParensCount -- ;
799
+ }
800
+
801
+ endIndex ++ ;
802
+ }
783
803
784
- logger . withInfo (
785
- "Successfully executed regex matching" ,
786
- integrationName ,
787
- CI_COMMIT_SHA ,
788
- "getAssetName"
789
- ) ;
804
+ const endMarker = '}}' ;
805
+ const finalEndIndex = fileContent . indexOf ( endMarker , endIndex ) + endMarker . length ;
790
806
791
- if ( matches ) {
792
- logger . withInfo (
793
- `Found a match: ${ matches [ 1 ] . trim ( ) } ` ,
794
- integrationName ,
795
- CI_COMMIT_SHA ,
796
- "getAssetName"
797
- ) ;
798
- return matches [ 1 ] . trim ( ) ;
807
+ configSection = fileContent . substring ( startIndex , finalEndIndex ) ;
808
+ logger . withInfo (
809
+ "Extracted config section" ,
810
+ integrationName ,
811
+ CI_COMMIT_SHA ,
812
+ "getAssetName"
813
+ ) ;
814
+
815
+ if ( configSection ) {
816
+ logger . withInfo (
817
+ "Executing final regex" ,
818
+ integrationName ,
819
+ CI_COMMIT_SHA ,
820
+ "getAssetName"
821
+ ) ;
822
+
823
+ var matches = regExp . exec ( configSection ) ;
824
+
825
+ logger . withInfo (
826
+ "Successfully executed regex matching" ,
827
+ integrationName ,
828
+ CI_COMMIT_SHA ,
829
+ "getAssetName"
830
+ ) ;
831
+
832
+ }
833
+ if ( matches ) {
834
+ logger . withInfo (
835
+ `Found a match: ${ matches [ 1 ] . trim ( ) } ` ,
836
+ integrationName ,
837
+ CI_COMMIT_SHA ,
838
+ "getAssetName"
839
+ ) ;
840
+
841
+ return matches [ 1 ] . trim ( ) ;
842
+ }
799
843
}
800
844
}
801
845
0 commit comments