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

Function buildSetupAction

pkg/cli/actions_build_command.go:304–341  ·  view source on GitHub ↗

buildSetupAction builds the setup action by checking that source files exist. Note: Both JavaScript and shell scripts are source of truth in actions/setup/js/ and actions/setup/sh/ These files are manually edited and committed to git. They are NOT synced to pkg/workflow/ At runtime, setup.sh copies

(actionsDir, actionName string)

Source from the content-addressed store, hash-verified

302// These files are manually edited and committed to git. They are NOT synced to pkg/workflow/
303// At runtime, setup.sh copies these files to /tmp/gh-aw/actions for workflow execution.
304func buildSetupAction(actionsDir, actionName string) error {
305 actionsBuildLog.Printf("Building setup action: actionsDir=%s, actionName=%s", actionsDir, actionName)
306 actionPath := filepath.Join(actionsDir, actionName)
307 jsDir := filepath.Join(actionPath, "js")
308 shDir := filepath.Join(actionPath, "sh")
309
310 // JavaScript files in actions/setup/js/ are the source of truth
311 if fileutil.DirExists(jsDir) {
312 // Count JavaScript files
313 entries, err := os.ReadDir(jsDir)
314 if err == nil {
315 jsCount := 0
316 for _, entry := range entries {
317 if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".cjs") {
318 jsCount++
319 }
320 }
321 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" ✓ JavaScript files in js/ (source of truth): %d", jsCount)))
322 }
323 }
324
325 // Shell scripts in actions/setup/sh/ are the source of truth
326 if fileutil.DirExists(shDir) {
327 // Count shell scripts
328 entries, err := os.ReadDir(shDir)
329 if err == nil {
330 shCount := 0
331 for _, entry := range entries {
332 if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".sh") {
333 shCount++
334 }
335 }
336 fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf(" ✓ Shell scripts in sh/ (source of truth): %d", shCount)))
337 }
338 }
339
340 return nil
341}
342
343// getActionDependencies returns the list of JavaScript dependencies for an action
344// This mapping defines which files from pkg/workflow/js/ are needed for each action

Callers 1

buildActionFunction · 0.85

Calls 3

DirExistsFunction · 0.92
FormatInfoMessageFunction · 0.92
PrintfMethod · 0.45

Tested by

no test coverage detected