TypeScript Action Template
October 3, 2025 ยท View on GitHub
A highly optimized GitHub Action template repository for building robust, performant TypeScript-based GitHub Actions with minimal bundle size and comprehensive code quality tooling.
Features
- ๐ 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
Project Structure
โโโ .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
Setup
- Clone this repository
- Install dependencies:
npm install
- Use the correct Node.js version:
nvm use
Development
Available Scripts
npm 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
Local Development
Test the action locally using the dev script:
npm run dev
This uses @github/local-action to run the action with your local source code.
Testing
Run tests with coverage:
npm test
Coverage reports are generated in the coverage/ directory, and a badge is
created in badges/coverage.svg.
Code Quality
Check for code duplication:
npm run duplication
Check for circular dependencies:
npm run madge
Building
Build the action for distribution:
npm run package
This creates the bundled dist/index.mjs file.
CI/CD
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
Usage in Workflows
- name: Run TypeScript Action
uses: your-org/your-action@v1
with:
# Add your inputs here
Configuration
Node.js Version
The project uses Node.js 20 (specified in .nvmrc).
TypeScript
- Production config:
tsconfig.json- Main configuration for builds and type checking - Test config:
tsconfig.test.json- Extends main config with test environment support
Code Quality & Linting
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
Formatting
Prettier is configured with:
- 2-space indentation
- Single quotes
- Semicolons
- 80 character line width
Build
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
Configuration Files Summary
| 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 |
Usage in Your Action
- 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
Contributing
- 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
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.