@@ -68,6 +68,10 @@ export function scanGeneratedWorkflows(
6868/**
6969 * Update hardcoded action versions in pr-checks/sync.ts
7070 *
71+ * Handles both inline `uses: "owner/action@ref"` strings and SHA-pinned
72+ * references expressed via the `pinnedUses("owner/action", "<sha>", "version")`
73+ * helper.
74+ *
7175 * @param syncTsPath - Path to sync.ts file
7276 * @param actionVersions - Map of action names to versions (may include comments)
7377 * @returns True if the file was modified, false otherwise
@@ -87,18 +91,36 @@ export function updateSyncTs(
8791 for ( const [ actionName , versionWithComment ] of Object . entries (
8892 actionVersions ,
8993 ) ) {
90- // Extract just the version part (before any comment) for sync.ts
91- const version = versionWithComment . includes ( "#" )
94+ // Split the scanned value into the ref (e.g. a commit SHA) and the optional
95+ // trailing version comment (e.g. `v6.0.3`).
96+ const ref = versionWithComment . includes ( "#" )
9297 ? versionWithComment . split ( "#" ) [ 0 ] . trim ( )
9398 : versionWithComment . trim ( ) ;
99+ const versionComment = versionWithComment . includes ( "#" )
100+ ? versionWithComment . split ( "#" ) [ 1 ] . trim ( )
101+ : "" ;
102+
103+ const escaped = actionName . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ;
94104
95105 // Look for patterns like uses: "actions/setup-node@v4"
96106 // Note that this will break if we store an Action uses reference in a
97107 // variable - that's a risk we're happy to take since in that case the
98108 // PR checks will just fail.
99- const escaped = actionName . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, "\\$&" ) ;
100- const pattern = new RegExp ( `(uses:\\s*")${ escaped } @(?:[^"]+)(")` , "g" ) ;
101- content = content . replace ( pattern , `$1${ actionName } @${ version } $2` ) ;
109+ const usesPattern = new RegExp ( `(uses:\\s*")${ escaped } @(?:[^"]+)(")` , "g" ) ;
110+ content = content . replace ( usesPattern , `$1${ actionName } @${ ref } $2` ) ;
111+
112+ // Look for SHA-pinned references expressed via the `pinnedUses` helper, e.g.
113+ // `pinnedUses("actions/checkout", "<sha>", "v6.0.3")`, updating both the
114+ // pinned ref and the version comment.
115+ const pinnedPattern = new RegExp (
116+ `(pinnedUses\\(\\s*")${ escaped } ("\\s*,\\s*")[^"]*("\\s*,\\s*")([^"]*)(")` ,
117+ "g" ,
118+ ) ;
119+ content = content . replace (
120+ pinnedPattern ,
121+ ( _match , p1 , p2 , p3 , oldVersion , p5 ) =>
122+ `${ p1 } ${ actionName } ${ p2 } ${ ref } ${ p3 } ${ versionComment || oldVersion } ${ p5 } ` ,
123+ ) ;
102124 }
103125
104126 if ( content !== originalContent ) {
0 commit comments