@@ -591,98 +591,3 @@ func (c *Compiler) generateOutputCollectionStep(yaml *strings.Builder, data *Wor
591591 yaml .WriteString (" if-no-files-found: warn\n " )
592592
593593}
594-
595- // collectUsedActionPins scans the YAML content for uses: directives and returns a map of used action pins
596- // The returned map keys are action repository names, and values are ActionPin structs
597- func collectUsedActionPins (yamlContent string ) map [string ]ActionPin {
598- usedPins := make (map [string ]ActionPin )
599-
600- // Scan each line for "uses:" directives
601- lines := strings .Split (yamlContent , "\n " )
602- for _ , line := range lines {
603- trimmed := strings .TrimSpace (line )
604-
605- // Match both "uses:" and "- uses:" (step format)
606- var usesValue string
607- if strings .HasPrefix (trimmed , "uses:" ) {
608- // Format: "uses: owner/repo@sha"
609- parts := strings .SplitN (trimmed , ":" , 2 )
610- if len (parts ) == 2 {
611- usesValue = strings .TrimSpace (parts [1 ])
612- }
613- } else if strings .HasPrefix (trimmed , "- uses:" ) {
614- // Format: "- uses: owner/repo@sha"
615- parts := strings .SplitN (trimmed , ":" , 2 )
616- if len (parts ) == 2 {
617- usesValue = strings .TrimSpace (parts [1 ])
618- }
619- }
620-
621- if usesValue == "" {
622- continue
623- }
624-
625- // Extract the repository part (before @)
626- actionRepo := extractActionRepo (usesValue )
627- if actionRepo == "" {
628- continue
629- }
630-
631- // Check if this action is in our pinned actions
632- if pin , exists := GetActionPinByRepo (actionRepo ); exists {
633- usedPins [actionRepo ] = pin
634- }
635- }
636-
637- return usedPins
638- }
639-
640- // generatePinnedActionsComment generates a comment section listing all pinned actions used in the workflow
641- // The comment includes the repository, version tag, SHA, and GitHub URL for each action
642- func generatePinnedActionsComment (usedPins map [string ]ActionPin ) string {
643- if len (usedPins ) == 0 {
644- return ""
645- }
646-
647- // Sort the pins by repository name for consistent output
648- sortedRepos := make ([]string , 0 , len (usedPins ))
649- for repo := range usedPins {
650- sortedRepos = append (sortedRepos , repo )
651- }
652-
653- // Simple bubble sort for consistency
654- for i := 0 ; i < len (sortedRepos ); i ++ {
655- for j := i + 1 ; j < len (sortedRepos ); j ++ {
656- if sortedRepos [i ] > sortedRepos [j ] {
657- sortedRepos [i ], sortedRepos [j ] = sortedRepos [j ], sortedRepos [i ]
658- }
659- }
660- }
661-
662- var comment strings.Builder
663- comment .WriteString ("#\n " )
664- comment .WriteString ("# Pinned GitHub Actions:\n " )
665-
666- for _ , repo := range sortedRepos {
667- pin := usedPins [repo ]
668- // Generate the GitHub URL to the specific commit
669- // For "actions/checkout" -> "https://github.com/actions/checkout/commit/08c6903..."
670- // For "github/codeql-action/upload-sarif" -> "https://github.com/github/codeql-action/commit/562257d..."
671-
672- // Extract the base repository (owner/repo) from potentially nested paths
673- var baseRepo string
674- repoParts := strings .Split (repo , "/" )
675- if len (repoParts ) >= 2 {
676- baseRepo = repoParts [0 ] + "/" + repoParts [1 ]
677- } else {
678- baseRepo = repo
679- }
680-
681- githubURL := fmt .Sprintf ("https://github.com/%s/commit/%s" , baseRepo , pin .SHA )
682-
683- comment .WriteString (fmt .Sprintf ("# - %s@%s (%s)\n " , repo , pin .Version , pin .SHA ))
684- comment .WriteString (fmt .Sprintf ("# %s\n " , githubURL ))
685- }
686-
687- return comment .String ()
688- }
0 commit comments