javascript-refactoring
JavaScript Code Refactoring Guide
This guide explains how to refactor JavaScript code into a separate .cjs file in the gh-aw repository. Follow these steps when extracting shared functionality or creating new JavaScript modules.
Overview
The gh-aw project uses CommonJS modules (.cjs files) for JavaScript code that runs in GitHub Actions workflows. These files are:
- Embedded in the Go binary using
//go:embeddirectives - Bundled using a custom JavaScript bundler that inlines local
require()calls - Executed in GitHub Actions using
actions/github-script@v8
Top-Level Script Pattern
Top-level .cjs scripts (those that are executed directly in workflows) follow a specific pattern:
✅ Correct Pattern - Export main, but don't call it:
async function main() {
More from github/gh-aw
github-mcp-server
GitHub MCP Server Documentation
43developer
Developer Instructions for GitHub Agentic Workflows
38dictation instructions
Instructions for fixing speech-to-text errors and improving text quality in gh-aw documentation and workflows
33github-pr-query
Query GitHub pull requests efficiently with jq argument support for filtering
31documentation
Documentation Brief description for SEO and navigation
30error-messages
Error Message Style Guide for Validation Errors
29