Skip to main content
github-actions-workflow-ts logo

github-actions-workflow-ts

Write GitHub Actions workflows in TypeScript instead of YAML

Type Safety

Full TypeScript support with auto-generated types from the official GitHub Actions schema. Catch errors at compile time.

Reusable Components

Define steps, jobs, and workflows once and reuse them across your projects. No more copy-pasting YAML.

Zero Dependencies

The core library has zero runtime dependencies and works in both ESM and CommonJS projects.

Write TypeScript, Generate YAML

1

Write your workflow in TypeScript

workflows/ci.wac.ts
import { 
Workflow,
NormalJob,
Step,
expressions as ex
} from '@github-actions-workflow-ts/lib'
import {
ActionsCheckoutV4,
ActionsSetupNodeV4
} from '@github-actions-workflow-ts/actions'

// Typed actions: autocomplete on inputs, typed outputs
const checkout = new ActionsCheckoutV4({ name: 'Checkout' })

const setupNode = new ActionsSetupNodeV4({
id: 'setup-node',
name: 'Setup Node.js',
with: { 'node-version': '20.x', cache: 'npm' },
})

// Plain steps work too
const test = new Step({
name: 'Run tests',
run: 'npm test',
env: { CI: 'true', NODE_AUTH_TOKEN: ex.secret('NPM_TOKEN') },
})

const testJob = new NormalJob('test', {
'runs-on': 'ubuntu-latest',
}).addSteps([checkout, setupNode, test])

export const ci = new Workflow('ci', {
name: 'CI',
on: {
push: { branches: ['main'] },
pull_request: { branches: ['main'] },
},
}).addJobs([testJob])
2

Run the build command

npx gwf build
3

Get your generated YAML workflow file

.github/workflows/ci.yml
# Generated by github-actions-workflow-ts
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
id: setup-node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: npm
- name: Run tests
run: npm test
env:
CI: "true"
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}