Skip to content

Commit 2c55703

Browse files
Copilotpelikhan
andcommitted
Move actions commands to internal tool
Moved actions-build, actions-validate, and actions-clean commands out of the main gh-aw CLI into an internal development tool: - Created internal/tools/actions-build/main.go as lightweight CLI dispatcher - Removed action commands from cmd/gh-aw/main.go (no longer in end-user CLI) - Updated Makefile to invoke internal tool: go run ./internal/tools/actions-build - Updated specs/actions.md to document internal tool architecture - Commands remain available via Makefile: make actions-build, etc. These are development-only commands not intended for end users, so they belong in an internal tool rather than the main CLI. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 933ec75 commit 2c55703

6 files changed

Lines changed: 68 additions & 158 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,17 @@ clean:
174174
.PHONY: actions-build
175175
actions-build:
176176
@echo "Building all actions..."
177-
@go run ./cmd/gh-aw actions-build
177+
@go run ./internal/tools/actions-build build
178178

179179
.PHONY: actions-validate
180180
actions-validate:
181181
@echo "Validating action.yml files..."
182-
@go run ./cmd/gh-aw actions-validate
182+
@go run ./internal/tools/actions-build validate
183183

184184
.PHONY: actions-clean
185185
actions-clean:
186186
@echo "Cleaning action artifacts..."
187-
@go run ./cmd/gh-aw actions-clean
187+
@go run ./internal/tools/actions-build clean
188188

189189
# Check Node.js version
190190
.PHONY: check-node-version

actions/setup-safe-inputs/index.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

actions/setup-safe-outputs/index.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

cmd/gh-aw/main.go

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -300,43 +300,6 @@ var versionCmd = &cobra.Command{
300300
},
301301
}
302302

303-
var actionsBuildCmd = &cobra.Command{
304-
Use: "actions-build",
305-
Short: "Build all custom GitHub Actions from source",
306-
Long: `Build all custom GitHub Actions by bundling JavaScript dependencies.
307-
308-
This command processes actions in the actions/ directory, reads their source files from src/,
309-
embeds required JavaScript dependencies from pkg/workflow/js/, and generates bundled index.js files.
310-
311-
The build process uses the same bundler infrastructure used for workflow compilation.`,
312-
RunE: func(cmd *cobra.Command, args []string) error {
313-
return cli.ActionsBuildCommand()
314-
},
315-
}
316-
317-
var actionsValidateCmd = &cobra.Command{
318-
Use: "actions-validate",
319-
Short: "Validate action.yml files",
320-
Long: `Validate all action.yml files in the actions/ directory.
321-
322-
Checks that each action.yml contains required fields (name, description, runs)
323-
and uses the correct runtime (node20).`,
324-
RunE: func(cmd *cobra.Command, args []string) error {
325-
return cli.ActionsValidateCommand()
326-
},
327-
}
328-
329-
var actionsCleanCmd = &cobra.Command{
330-
Use: "actions-clean",
331-
Short: "Clean generated action files",
332-
Long: `Remove generated index.js files from all actions in the actions/ directory.
333-
334-
This is useful for starting fresh or before rebuilding all actions.`,
335-
RunE: func(cmd *cobra.Command, args []string) error {
336-
return cli.ActionsCleanCommand()
337-
},
338-
}
339-
340303
func init() {
341304
// Add command groups to root command
342305
rootCmd.AddGroup(&cobra.Group{
@@ -538,9 +501,6 @@ Use "` + constants.CLIExtensionPrefix + ` help all" to show help for all command
538501
statusCmd.GroupID = "development"
539502
mcpServerCmd.GroupID = "development"
540503
mcpGatewayCmd.GroupID = "development"
541-
actionsBuildCmd.GroupID = "development"
542-
actionsValidateCmd.GroupID = "development"
543-
actionsCleanCmd.GroupID = "development"
544504

545505
// Execution Commands
546506
runCmd.GroupID = "execution"
@@ -574,9 +534,6 @@ Use "` + constants.CLIExtensionPrefix + ` help all" to show help for all command
574534
rootCmd.AddCommand(mcpCmd)
575535
rootCmd.AddCommand(mcpServerCmd)
576536
rootCmd.AddCommand(mcpGatewayCmd)
577-
rootCmd.AddCommand(actionsBuildCmd)
578-
rootCmd.AddCommand(actionsValidateCmd)
579-
rootCmd.AddCommand(actionsCleanCmd)
580537
rootCmd.AddCommand(prCmd)
581538
rootCmd.AddCommand(versionCmd)
582539
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/githubnext/gh-aw/pkg/cli"
8+
)
9+
10+
func main() {
11+
if len(os.Args) < 2 {
12+
fmt.Fprintln(os.Stderr, "Usage: actions-build <command>")
13+
fmt.Fprintln(os.Stderr, "")
14+
fmt.Fprintln(os.Stderr, "Commands:")
15+
fmt.Fprintln(os.Stderr, " build Build all custom GitHub Actions")
16+
fmt.Fprintln(os.Stderr, " validate Validate all action.yml files")
17+
fmt.Fprintln(os.Stderr, " clean Remove generated index.js files")
18+
os.Exit(1)
19+
}
20+
21+
command := os.Args[1]
22+
var err error
23+
24+
switch command {
25+
case "build":
26+
err = cli.ActionsBuildCommand()
27+
case "validate":
28+
err = cli.ActionsValidateCommand()
29+
case "clean":
30+
err = cli.ActionsCleanCommand()
31+
default:
32+
fmt.Fprintf(os.Stderr, "Unknown command: %s\n", command)
33+
os.Exit(1)
34+
}
35+
36+
if err != nil {
37+
fmt.Fprintln(os.Stderr, err)
38+
os.Exit(1)
39+
}
40+
}

specs/actions.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,26 @@ Create a custom actions system that:
4848

4949
```
5050
┌─────────────────────────────────────────────────────────┐
51-
│ Makefile Targets
51+
│ Makefile Interface
5252
│ ┌────────────────────────────────────────────────────┐ │
53-
│ │ actions-build │ actions-validate │ actions-clean│ │
53+
│ │ make actions-build │ make actions-validate │ │
54+
│ │ make actions-clean │ │
5455
│ └────────────────────────────────────────────────────┘ │
5556
└─────────────────────────────────────────────────────────┘
5657
57-
▼ (go run ./cmd/gh-aw)
58+
▼ (go run internal/tools/actions-build)
59+
┌─────────────────────────────────────────────────────────┐
60+
│ internal/tools/actions-build/main.go │
61+
│ (Internal Development Tool) │
62+
│ ┌────────────────────────────────────────────────────┐ │
63+
│ │ Simple CLI dispatcher for: │ │
64+
│ │ • build command │ │
65+
│ │ • validate command │ │
66+
│ │ • clean command │ │
67+
│ └────────────────────────────────────────────────────┘ │
68+
└─────────────────────────────────────────────────────────┘
69+
70+
5871
┌─────────────────────────────────────────────────────────┐
5972
│ pkg/cli/actions_build_command.go │
6073
│ (Pure Go Implementation) │
@@ -92,15 +105,15 @@ Create a custom actions system that:
92105

93106
### Component Responsibilities
94107

95-
#### 1. Makefile Targets (`Makefile`)
96-
- Entry points for action management: `actions-build`, `actions-validate`, `actions-clean`
97-
- Invokes Go commands directly using `go run ./cmd/gh-aw`
108+
#### 1. Makefile Interface (`Makefile`)
109+
- Primary entry point for building actions: `make actions-build`, `make actions-validate`, `make actions-clean`
110+
- Invokes internal tool via `go run ./internal/tools/actions-build <command>`
98111
- Project-specific development commands (not end-user CLI)
99112

100-
#### 2. CLI Command Registration (`cmd/gh-aw/main.go`)
101-
- Cobra command definitions for actions commands
102-
- Integrated into `gh aw` command hierarchy under "Development Commands" group
103-
- Commands delegate to `pkg/cli/actions_build_command.go`
113+
#### 2. Internal Tool (`internal/tools/actions-build/main.go`)
114+
- Lightweight CLI dispatcher for development-only commands
115+
- Not part of the main `gh aw` CLI (which is for end users)
116+
- Routes commands to appropriate functions in `pkg/cli`
104117

105118
#### 3. Build System Implementation (`pkg/cli/actions_build_command.go`)
106119
- **Pure Go implementation** - No JavaScript build scripts
@@ -541,13 +554,13 @@ The CI runs when:
541554
#### Key Files to Know
542555

543556
- `pkg/cli/actions_build_command.go` - **Pure Go build system** (no JavaScript)
557+
- `internal/tools/actions-build/main.go` - Internal CLI tool dispatcher (development only)
544558
- `pkg/workflow/js.go` - JavaScript source map and embedded files
545-
- `cmd/gh-aw/main.go` - CLI command definitions (invoked by Makefile)
546559
- `Makefile` - Primary interface for building actions (`make actions-build`)
547560
- `.github/workflows/ci.yml` - CI validation
548561
- `actions/README.md` - Actions documentation
549562

550-
**Important**: Build process is 100% Go code. No `scripts/build-actions.js` or similar JavaScript build scripts exist.
563+
**Important**: Build process is 100% Go code. No `scripts/build-actions.js` or similar JavaScript build scripts exist. Commands are invoked via Makefile, which runs the internal tool at `internal/tools/actions-build`.
551564

552565
#### Debugging Tips
553566

0 commit comments

Comments
 (0)