A highly optimized GitHub Action template repository for building robust, performant TypeScript-based GitHub Actions with minimal bundle size and comprehensive code quality tooling.
- π High Performance: Optimized 1.3KB bundle size (99.7% reduction from typical builds)
- π¦ Modern TypeScript: Full TypeScript configuration with strict type checking
- π Code Quality: ESLint with SonarJS static analysis, complexity limits, and import sorting
- π¨ Code Formatting: Prettier integration with automatic formatting
- π§ͺ Comprehensive Testing: Jest testing framework with coverage reporting and badges
- β‘ Optimized Build: Rollup bundling with external dependencies and Terser minification
- ποΈ Smart Architecture: Modular logging system with dependency injection
- π Quality Gates: Duplicate code detection (1% threshold), circular dependency checking
- π‘οΈ Security: SonarJS security patterns and vulnerability detection
- π§ Developer Experience: Local development support with @github/local-action
- π CI/CD Ready: Pre-configured GitHub Actions workflows with quality gates
βββ .devcontainer/ # Dev container configuration
βββ .github/
β βββ workflows/ # GitHub Actions CI/CD workflows
β β βββ ci.yml # Main CI pipeline
β β βββ check-dist.yml # Distribution verification
β βββ FUNDING.yml # GitHub funding configuration
β βββ pull_request_template.md
βββ .vscode/ # VS Code workspace settings
βββ __mocks__/ # Test mocks
β βββ @actions/
β βββ core.ts
βββ badges/ # Generated coverage badges
βββ coverage/ # Test coverage reports
βββ dist/ # Build output
βββ script/ # Utility scripts
β βββ copyright.sh # Copyright header management
β βββ distchk.sh # Distribution verification
β βββ release.sh # Release automation
βββ src/
β βββ index.ts # Main entry point
β βββ core/ # Core action logic
β β βββ action.ts # Action implementation
β β βββ index.ts # Core exports
β βββ logging/ # Modular logging system
β β βββ loggers/ # Logger implementations
β β β βββ composite.ts # Multi-logger coordination
β β β βββ core.ts # GitHub Actions logger
β β β βββ filtered.ts # Filtered logging
β β β βββ metrics.ts # Metrics collection
β β β βββ mock.ts # Test mock logger
β β β βββ noop.ts # No-op logger
β β βββ pino/ # Pino logger integration
β β βββ filters/ # Log filtering system
β β βββ config.ts # Logger configuration
β β βββ types.ts # Type definitions
β β βββ index.ts # Logging exports
β βββ __tests__/ # Comprehensive test suite
βββ .editorconfig # Editor style configuration
βββ .gitignore # Optimized git ignore rules
βββ .gitattributes # Git attributes
βββ .jscpd.json # Code duplication detection config
βββ .markdown-lint.yml # Markdown linting configuration
βββ .npmignore # NPM publish control
βββ .nvmrc # Node.js version (20)
βββ .prettierignore # Prettier ignore rules
βββ .prettierrc.yml # Prettier configuration
βββ .yaml-lint.yml # YAML linting configuration
βββ action.yml # GitHub Action metadata
βββ CODEOWNERS # Code ownership rules
βββ eslint.config.mjs # Modern ESLint flat configuration
βββ jest.config.cjs # Jest testing configuration
βββ package.json # Optimized dependencies and scripts
βββ rollup.config.js # Optimized build configuration
βββ tsconfig.json # Production TypeScript config
βββ tsconfig.test.json # Test environment TypeScript config
βββ README.md # This file
- Clone this repository
- Install dependencies:
npm install- Use the correct Node.js version:
nvm usenpm run all- π Complete pipeline: lint:fix β quality β test β packagenpm run dev- π§ Local development with @github/local-actionnpm run typecheck- π TypeScript type checking without emitnpm run lint- π Prettier and ESLint validationnpm run lint:fix- π¨ Autoformat and fix code issuesnpm run quality- π Quality gates: lint + duplication + circular depsnpm test- π§ͺ Jest tests with coverage reportingnpm run coverage- π Generate coverage badgenpm run duplication- π Code duplication analysis (1% threshold)npm run madge- π Circular dependency detectionnpm run package- π¦ Production build (optimized 1.3KB bundle)npm run package:watch- π Watch mode for developmentnpm run copyright- Β©οΈ Update copyright headersnpm run release- π Prepare distribution for release
Test the action locally using the dev script:
npm run devThis uses @github/local-action to run the action with your local source code.
Run tests with coverage:
npm testCoverage reports are generated in the coverage/ directory, and a badge is
created in badges/coverage.svg.
Check for code duplication:
npm run duplicationCheck for circular dependencies:
npm run madgeBuild the action for distribution:
npm run packageThis creates the bundled dist/index.mjs file.
The repository includes comprehensive CI/CD workflows:
- CI Pipeline (
ci.yml): Runs linting, unit tests, and integration tests - Distribution Check (
check-dist.yml): Ensures thedist/directory matches the built output
- name: Run TypeScript Action
uses: your-org/your-action@v1
with:
# Add your inputs hereThe project uses Node.js 20 (specified in .nvmrc).
- Production config:
tsconfig.json- Main configuration for builds and type checking - Test config:
tsconfig.test.json- Extends main config with test environment support
ESLint with modern flat configuration includes:
- TypeScript Integration: Full type-aware linting with strict rules
- SonarJS Static Analysis: Security patterns, complexity limits, code smells
- Import Organization: Automatic import sorting and organization
- Complexity Monitoring: Cyclomatic complexity limits (fails build at >10)
- Jest Support: Test-specific rules and globals
- Prettier Integration: Seamless code formatting
Prettier is configured with:
- 2-space indentation
- Single quotes
- Semicolons
- 80 character line width
Rollup produces an optimized bundle with:
- 99.7% Size Reduction: From 451KB to 1.3KB (external dependencies)
- ES Module Output: Modern JavaScript for GitHub Actions
- Terser Minification: Optimized production build
- External Dependencies: Core Node.js and GitHub Action modules
- Source Maps: Full debugging support
| File | Purpose | Key Features |
|---|---|---|
action.yml |
GitHub Action metadata | Defines inputs, outputs, and Node.js runtime |
package.json |
Project configuration | Optimized scripts, 24 dependencies (down from 32) |
tsconfig.json |
TypeScript production config | Strict rules, ECMAScript 2022 target, Node.js resolution |
tsconfig.test.json |
TypeScript test config | Extends base with Jest globals and test types |
eslint.config.mjs |
ESLint flat configuration | SonarJS rules, import organization, complexity limits |
jest.config.cjs |
Jest testing framework | Coverage reports, TypeScript transformation |
rollup.config.js |
Build tool configuration | 99.7% bundle reduction, external dependencies |
- Clone this template or use it as a GitHub template
- Customize
action.ymlwith your action's metadata - Implement your logic in
src/core/action.ts - Add tests in
src/__tests__/ - Run the full pipeline with
npm run all - Build and release with
npm run package
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following the existing patterns
- Add comprehensive tests for new functionality
- Run the complete pipeline:
npm run all - Ensure all quality gates pass (linting, tests, coverage)
- Submit a pull request with a clear description
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.