Skip to content

@ghagen/ghagen

Custom GitHub Action definitions and runners.

Function Description

action

Create an action model representing a complete action.yml definition.

This is the top-level factory for GitHub Actions action metadata. Pass the returned model to toYaml or toYamlFile to emit the YAML.

Example

const myAction = action({
name: "Hello World",
description: "Greet someone",
inputs: { name: actionInputDef({ description: "Who to greet", required: true }) },
runs: nodeRuns({ using: "node20", main: "dist/index.js" }),
});

actionInputDef

Create an action input definition model.

Produces a model for a single entry in the action’s inputs map.

Example

const nameInput = actionInputDef({
description: "Name to greet",
required: true,
default: "World",
});

actionOutputDef

Create an action output definition model.

Produces a model for a single entry in the action’s outputs map.

Example

const timeOutput = actionOutputDef({
description: "The greeting timestamp",
value: "${{ steps.greet.outputs.time }}",
});

branding

Create a branding model for a GitHub Actions Marketplace listing.

Example

const badge = branding({ icon: "award", color: "green" });

compositeRuns

Create a composite runs model.

Defines the runs section of a composite action, containing an ordered list of StepModel entries.

Example

const runs = compositeRuns({
using: "composite",
steps: [step({ run: "echo Hello" })],
});

dockerRuns

Create a Docker runs model.

Defines the runs section of a Docker container action, specifying the image, entrypoint, arguments, and lifecycle hooks.

Example

const runs = dockerRuns({
using: "docker",
image: "Dockerfile",
args: ["--name", "${{ inputs.name }}"],
});

nodeRuns

Create a Node.js runs model.

Defines the runs section of a JavaScript/TypeScript action, specifying the Node.js version, entry-point script, and optional pre/post hooks.

Example

const runs = nodeRuns({
using: "node20",
main: "dist/index.js",
post: "dist/cleanup.js",
});