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

Function getActionDirectories

pkg/cli/actions_build_command.go:136–152  ·  view source on GitHub ↗

getActionDirectories returns a sorted list of action directory names

(actionsDir string)

Source from the content-addressed store, hash-verified

134
135// getActionDirectories returns a sorted list of action directory names
136func getActionDirectories(actionsDir string) ([]string, error) {
137 if _, err := os.Stat(actionsDir); os.IsNotExist(err) {
138 return nil, errors.New("actions/ directory does not exist")
139 }
140
141 entries, err := os.ReadDir(actionsDir)
142 if err != nil {
143 return nil, fmt.Errorf("failed to read actions directory: %w", err)
144 }
145
146 dirEntries := sliceutil.Filter(entries, func(e os.DirEntry) bool { return e.IsDir() })
147 dirs := sliceutil.Map(dirEntries, func(e os.DirEntry) string { return e.Name() })
148
149 sort.Strings(dirs)
150 actionsBuildLog.Printf("Found %d action directories in %s", len(dirs), actionsDir)
151 return dirs, nil
152}
153
154// validateActionYml validates that an action.yml file exists and contains required fields.
155//

Callers 5

ActionsBuildCommandFunction · 0.85
ActionsValidateCommandFunction · 0.85
ActionsCleanCommandFunction · 0.85
TestGetActionDirectoriesFunction · 0.85

Calls 4

FilterFunction · 0.92
MapFunction · 0.92
ErrorfMethod · 0.45
PrintfMethod · 0.45

Tested by 2

TestGetActionDirectoriesFunction · 0.68