Skip to content

Commit ec0f11a

Browse files
Copilotpelikhan
andcommitted
Migrate actions build to Go using bundler infrastructure
- Created pkg/cli/actions_build_command.go with Go-based build commands - Implemented ActionsBuildCommand, ActionsValidateCommand, ActionsCleanCommand - Reuses workflow bundler and script registry infrastructure from pkg/workflow - Added CLI commands: actions-build, actions-validate, actions-clean - Updated Makefile to use Go commands instead of Node.js script - Removed scripts/build-actions.js JavaScript build script - Added safe_outputs_tools.json to GetJavaScriptSources() map - Updated actions/README.md documentation The build system now leverages the same infrastructure as workflow compilation, eliminating duplicate bundling logic and providing better integration. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent 70622a7 commit ec0f11a

9 files changed

Lines changed: 363 additions & 278 deletions

File tree

.github/workflows/release.lock.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,19 +172,19 @@ clean:
172172

173173
# Actions management targets
174174
.PHONY: actions-build
175-
actions-build:
175+
actions-build: build
176176
@echo "Building all actions..."
177-
node scripts/build-actions.js build
177+
./gh-aw actions-build
178178

179179
.PHONY: actions-validate
180-
actions-validate:
180+
actions-validate: build
181181
@echo "Validating action.yml files..."
182-
node scripts/build-actions.js validate
182+
./gh-aw actions-validate
183183

184184
.PHONY: actions-clean
185-
actions-clean:
185+
actions-clean: build
186186
@echo "Cleaning action artifacts..."
187-
node scripts/build-actions.js clean
187+
./gh-aw actions-clean
188188

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

actions/README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,41 @@ Copies safe-inputs MCP server files to the agent environment. This action embeds
3131

3232
## Building Actions
3333

34-
Actions are built using the build tooling in `scripts/build-actions.js`. The build process:
34+
Actions are built using the Go-based build system that reuses the bundler and script registry infrastructure from the workflow compiler.
35+
36+
The build process:
3537

3638
1. Reads source files from `actions/{action-name}/src/`
3739
2. Identifies and embeds required JavaScript dependencies from `pkg/workflow/js/`
38-
3. Bundles everything into `actions/{action-name}/index.js`
39-
4. Validates `action.yml` files
40+
3. Uses the same bundler infrastructure as workflow compilation
41+
4. Bundles everything into `actions/{action-name}/index.js`
42+
5. Validates `action.yml` files
4043

4144
### Build Commands
4245

4346
```bash
4447
# Build all actions (generates index.js files)
4548
make actions-build
49+
# or
50+
gh aw actions-build
4651

4752
# Validate action.yml files
4853
make actions-validate
54+
# or
55+
gh aw actions-validate
4956

57+
# Clean generated files
5058
# Clean generated files
5159
make actions-clean
60+
# or
61+
gh aw actions-clean
5262
```
5363

64+
The build system uses:
65+
- **Bundler Infrastructure**: Same JavaScript bundler used for workflow compilation (`pkg/workflow/bundler.go`)
66+
- **Script Registry**: Centralized registry for managing JavaScript sources (`pkg/workflow/script_registry.go`)
67+
- **Embedded Sources**: All JavaScript files from `pkg/workflow/js/` via `GetJavaScriptSources()`
68+
5469
## Development Guidelines
5570

5671
### Creating a New Action
@@ -103,8 +118,8 @@ make actions-clean
103118
run();
104119
```
105120

106-
4. **Update build-actions.js:**
107-
Add the action to the `dependencyMap` in `scripts/build-actions.js` to specify which JavaScript files from `pkg/workflow/js/` should be embedded.
121+
4. **Update dependency mapping:**
122+
Add the action to the dependency map in `pkg/cli/actions_build_command.go` to specify which JavaScript files from `pkg/workflow/js/` should be embedded.
108123

109124
5. **Build and test:**
110125
```bash

actions/setup-safe-inputs/index.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/setup-safe-outputs/index.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/gh-aw/main.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,43 @@ 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+
303340
func init() {
304341
// Add command groups to root command
305342
rootCmd.AddGroup(&cobra.Group{
@@ -501,6 +538,9 @@ Use "` + constants.CLIExtensionPrefix + ` help all" to show help for all command
501538
statusCmd.GroupID = "development"
502539
mcpServerCmd.GroupID = "development"
503540
mcpGatewayCmd.GroupID = "development"
541+
actionsBuildCmd.GroupID = "development"
542+
actionsValidateCmd.GroupID = "development"
543+
actionsCleanCmd.GroupID = "development"
504544

505545
// Execution Commands
506546
runCmd.GroupID = "execution"
@@ -534,6 +574,9 @@ Use "` + constants.CLIExtensionPrefix + ` help all" to show help for all command
534574
rootCmd.AddCommand(mcpCmd)
535575
rootCmd.AddCommand(mcpServerCmd)
536576
rootCmd.AddCommand(mcpGatewayCmd)
577+
rootCmd.AddCommand(actionsBuildCmd)
578+
rootCmd.AddCommand(actionsValidateCmd)
579+
rootCmd.AddCommand(actionsCleanCmd)
537580
rootCmd.AddCommand(prCmd)
538581
rootCmd.AddCommand(versionCmd)
539582
}

0 commit comments

Comments
 (0)