- Add symlink from .forgejo/workflows to .github/workflows - Document Forgejo compatibility in README - Enable dual-platform support without code duplication |
||
|---|---|---|
| .forgejo | ||
| .github/workflows | ||
| .husky | ||
| hello-world | ||
| scripts | ||
| src | ||
| .biomeignore | ||
| .gitignore | ||
| biome.json | ||
| CLAUDE.md | ||
| commitlint.config.js | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| tsconfig.json | ||
GitHub Actions TypeScript Template
A modern TypeScript template for building GitHub Actions with minimal bundling and fast builds.
Features
- 🚀 TypeScript - Type-safe action development
- 📦 esbuild - Lightning-fast bundling
- 🧹 Biome - All-in-one linting and formatting
- 📌 pnpm - Fast, disk space efficient package manager
- 🎯 ES Modules - Modern JavaScript module system
Quick Start
# Install dependencies
pnpm install
# Build the action
pnpm build
# Run linting
pnpm lint
# Format code
pnpm format
# Type check
pnpm typecheck
Project Structure
.
├── src/ # TypeScript source files
│ └── hello-world.ts # Example action implementation
├── hello-world/ # Action directory
│ ├── action.yaml # Action metadata
│ └── index.js # Entry point
├── scripts/ # Build scripts
│ └── build.js # esbuild configuration
└── dist/ # Compiled output (git ignored)
Creating a New Action
-
Create your TypeScript file in
src/:import * as core from '@actions/core'; export async function run(): Promise<void> { // Your action logic here } -
Create an action directory with:
action.yaml- Action metadataindex.js- Entry point that imports from dist
-
Update
scripts/build.jsto include your new action -
Build and test your action
Testing the Action
The included workflow (.github/workflows/test-hello-world.yml) demonstrates how to test the action:
- name: Test Hello World Action
uses: ./hello-world
with:
name: 'GitHub Actions'
Using in Other Repositories
Once published, use your action in workflows:
- uses: your-username/your-repo@main
with:
name: 'World'
Development
This template uses:
- Node.js 20 - Latest LTS version
- pnpm 10 - Enabled via Corepack
- Biome v2 - Fast, modern linting and formatting
- esbuild - Bundles TypeScript with dependencies
Forgejo Compatibility
This template is compatible with both GitHub Actions and Forgejo Actions:
Setup for Forgejo
-
The repository includes a symlink from
.forgejo/workflowsto.github/workflows, so workflows work on both platforms automatically. -
Runner Compatibility: The default
ubuntu-latestrunner works on both platforms. For Forgejo instances that require specific runner configurations, you may need to adjust theruns-onvalues in workflows. -
Action References: Most action references (like
actions/checkout@v4) work on both platforms as Forgejo maintains compatibility with common GitHub Actions.
Platform-Specific Considerations
- Token: Both platforms provide
GITHUB_TOKENfor compatibility - Context Variables: GitHub context variables (like
github.event,github.repository) work on both platforms - Secrets: Both platforms support secrets in the same way
Testing on Forgejo
To test these actions on a Forgejo instance:
# Works on both GitHub and Forgejo
- uses: actions/checkout@v4
- uses: ./hello-world
with:
name: 'Forgejo'
License
MIT