@github-actions-workflow-ts/lib
v2.4.0
Published
Type-safe GitHub Actions workflow builder - Library
Readme
@github-actions-workflow-ts/lib
Type-safe GitHub Actions workflow builder library for TypeScript.
Stop writing workflows in YAML and use TypeScript instead!
Installation
Full Installation (recommended)
Install both the library and CLI to write workflows in TypeScript and generate YAML files:
npm install --save-dev @github-actions-workflow-ts/lib @github-actions-workflow-ts/cliLibrary Only
If you only want to generate workflow JSON objects and handle YAML file generation yourself, install just the zero-dependency library:
npm install --save-dev @github-actions-workflow-ts/libThe library package has zero dependencies and works in both ESM and CommonJS projects.
Quick Start
import { Workflow, NormalJob, Step } from '@github-actions-workflow-ts/lib'
const checkoutStep = new Step({
name: 'Checkout',
uses: 'actions/checkout@v3',
})
const testJob = new NormalJob('Test', {
'runs-on': 'ubuntu-latest',
'timeout-minutes': 2
})
export const exampleWorkflow = new Workflow('example-filename', {
name: 'Example',
on: {
workflow_dispatch: {}
}
})
testJob.addStep(checkoutStep)
exampleWorkflow.addJob(testJob)Documentation
For full documentation, examples, and API reference, visit the main repository.
Features
- Type Safety: Full TypeScript support with types generated from the official GitHub Actions Workflow JSON Schema
- Zero Dependencies: The library has no external dependencies
- Dual Module Support: Works with both ESM and CommonJS projects
- Intuitive API: Builder pattern for constructing workflows, jobs, and steps
- Expression Helpers: Utilities for GitHub Actions expressions like
${{ secrets.TOKEN }}
License
MIT
