A TypeScript library for writing GitHub Actions workflows and rendering them to YAML.
- Designed closely with
stefma/pkl-ghasemantics (but we don't do camel-case -> kebab-case conversions for actions) - Stable YAML rendering (Bun’s
Bun.YAMLor npmyaml)
Author GitHub Actions workflows in TypeScript with strong typing and helpful validation, then render to YAML for .github/workflows/.
- Strong typing: Catch errors at build-time instead of in CI.
- Deterministic YAML: Stable key ordering and converters.
If using Bun:
bunx jsr add -D @jlarky/gha-ts # or bun add -D @jlarky/gha-tsIf using Node.js:
npx nypm add -D @jlarky/gha-ts yaml # or npx jsr add -D @jlarky/gha-tsNotes:
- Bun users will import YAML from bun and node users will use
yamlfrom npm. - This example is using Bun, but you can find other examples in the examples directory.
Create a workflow module at .github/workflows/example-bun.main.ts (when using Bun):
#!/usr/bin/env bun
import { YAML } from "bun";
import { workflow } from "@jlarky/gha-ts/workflow-types";
import { checkout } from "@jlarky/gha-ts/actions";
import { generateWorkflow } from "@jlarky/gha-ts/cli";
const wf = workflow({
name: "Example workflow",
on: {
push: { branches: ["main"] },
pull_request: {},
},
jobs: {
exampleJob: {
"runs-on": "ubuntu-latest",
steps: [
checkout({ "fetch-depth": 0 }),
{ name: "Test", run: "echo 'Hello, world!'" },
],
},
},
});
await generateWorkflow(wf, YAML.stringify, import.meta.url);- Look at the .github/workflows directory for workflow examples.
- Additional usage examples:
src/examples/. - Hello world (Bun)
- Hello world (Node.js)
- Hello world (Deno)
MIT
- actions-toolkit
- ghats
- github-actions-typescript
- github-actions-typing
- github-actions-wac
- github-actions-workflow-ts
- workflow-ts
Non JavaScript/TypeScript: