Skip to content

@ghagen/ghagen

Job model and related configuration.

Function Description

container

Create a container model for use as a job-level container.

The returned model maps to the jobs.<job_id>.container key in a GitHub Actions workflow YAML.

Example

const pg = container({
image: "postgres:16",
env: { POSTGRES_PASSWORD: "postgres" },
ports: ["5432:5432"],
});

environment

Create an environment model for deployment environment configuration.

Example

environment({ name: "production", url: "https://example.com" })

job

Create a job model for use in a workflow’s jobs map. Plain-object values for permissions, environment, strategy, defaults, concurrency, container, and services entries are automatically wrapped with their respective factory functions.

Example

job({
name: "Test",
runsOn: "ubuntu-latest",
steps: [
step({ uses: "actions/checkout@v4" }),
step({ name: "Run tests", run: "npm test" }),
],
})

matrix

Create a matrix model for strategy configuration.

Example

matrix({
"node-version": ["18", "20"],
os: ["ubuntu-latest", "macos-latest"],
include: [{ os: "ubuntu-latest", experimental: true }],
})

service

Create a service container model.

Service containers run alongside the job and are accessible via their key in jobs.<job_id>.services. The input shape is identical to container, but the returned model is branded as a ServiceModel so it can only be placed in the services map.

Example

const redis = service({
image: "redis:7",
ports: ["6379:6379"],
});

strategy

Create a strategy model for controlling matrix builds.

Example

strategy({
matrix_: {
"node-version": ["18", "20"],
os: ["ubuntu-latest", "macos-latest"],
},
failFast: false,
})