MCPcopy Create free account
hub / github.com/github/gh-aw / ActionsCleanCommand

Function ActionsCleanCommand

pkg/cli/actions_build_command.go:95–133  ·  view source on GitHub ↗

ActionsCleanCommand removes generated index.js files from all actions

()

Source from the content-addressed store, hash-verified

93
94// ActionsCleanCommand removes generated index.js files from all actions
95func ActionsCleanCommand() error {
96 actionsDir := "actions"
97
98 actionsBuildLog.Print("Starting actions cleanup")
99
100 // Get list of action directories
101 actionDirs, err := getActionDirectories(actionsDir)
102 if err != nil {
103 return err
104 }
105
106 if len(actionDirs) == 0 {
107 fmt.Fprintln(os.Stderr, console.FormatWarningMessage("No action directories found in actions/"))
108 return nil
109 }
110
111 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("🧹 Cleaning generated action files"))
112
113 cleanedCount := 0
114 for _, actionName := range actionDirs {
115 // Clean index.js for actions that use it (except setup)
116 if actionName != "setup" {
117 indexPath := filepath.Join(actionsDir, actionName, "index.js")
118 if fileutil.FileExists(indexPath) {
119 if err := os.Remove(indexPath); err != nil {
120 return fmt.Errorf("failed to remove %s: %w", indexPath, err)
121 }
122 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" ✓ Removed %s/index.js", actionName)))
123 cleanedCount++
124 }
125 }
126
127 // For setup action, both js/ and sh/ directories are source of truth (NOT generated)
128 // Do not clean them
129 }
130
131 fmt.Fprintln(os.Stderr, console.FormatSuccessMessage(fmt.Sprintf("✨ Cleanup complete (%d files removed)", cleanedCount)))
132 return nil
133}
134
135// getActionDirectories returns a sorted list of action directory names
136func getActionDirectories(actionsDir string) ([]string, error) {

Callers 3

mainFunction · 0.92

Calls 7

FormatWarningMessageFunction · 0.92
FormatInfoMessageFunction · 0.92
FileExistsFunction · 0.92
FormatSuccessMessageFunction · 0.92
getActionDirectoriesFunction · 0.85
PrintMethod · 0.80
ErrorfMethod · 0.45