Generate GitHub Actions workflow YAML from Python code
Project description
ghagen
Generate GitHub Actions workflows from Python code.
Install
Homebrew (macOS, Linux)
brew install nathanjordan/tap/ghagen
pip / uv / pipx
pip install ghagen
uv tool install ghagen
pipx install ghagen
Example
from ghagen import App, Job, On, PRTrigger, PushTrigger, Step, Workflow
workflow = Workflow(
name="CI",
on=On(
push=PushTrigger(branches=["main"]),
pull_request=PRTrigger(branches=["main"]),
),
jobs={
"test": Job(
runs_on="ubuntu-latest",
steps=[
Step(uses="actions/checkout@v4"),
Step(name="Run tests", run="python -m pytest"),
],
),
},
)
app = App()
app.add_workflow(workflow, "ci.yml")
app.synth()
This generates:
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: python -m pytest
Features
- Typed models — Pydantic models for workflows, jobs, steps, triggers, and permissions with full IDE autocomplete
- YAML comments — block, end-of-line, and field-level comments preserved in output
- DRY helpers — step factories (
checkout(),setup_python(),setup_uv()) and expression builder (expr) - Escape hatches —
Raw[T],extras,post_process, andCommentedMappassthrough for anything the typed API doesn't cover - Linting —
ghagen lintcatches common problems (missingpermissions, unpinned actions, missingtimeout-minutes, duplicate step ids) at the Python level with source-line precision - CLI —
ghagen synthgenerates YAML,ghagen check-syncedverifies freshness in CI,ghagen lintruns rule-based checks,ghagen initscaffolds a starter config
Quick Start
# Scaffold a config file
ghagen init
# Generate workflow YAML
ghagen synth
# Verify workflows match Python definitions (for CI)
ghagen check-synced
# Lint workflow definitions
ghagen lint
Documentation
Full documentation: nathanjordan.github.io/ghagen
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghagen-0.3.1.tar.gz.
File metadata
- Download URL: ghagen-0.3.1.tar.gz
- Upload date:
- Size: 253.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8955e29772015f825b2a506feb122395f17eeccd96bd5255842cd5b739b880c
|
|
| MD5 |
f591fcb0c52b35bfcbc8469f7eab485f
|
|
| BLAKE2b-256 |
254ab5984f787e83f3d72d9d047db20e3e29984e713915b9e90d6e0d457011c5
|
Provenance
The following attestation bundles were made for ghagen-0.3.1.tar.gz:
Publisher:
release.yml on nathanjordan/ghagen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghagen-0.3.1.tar.gz -
Subject digest:
d8955e29772015f825b2a506feb122395f17eeccd96bd5255842cd5b739b880c - Sigstore transparency entry: 1292896069
- Sigstore integration time:
-
Permalink:
nathanjordan/ghagen@0139079eb2126a62a0274171f6a5376a047c5623 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nathanjordan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0139079eb2126a62a0274171f6a5376a047c5623 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ghagen-0.3.1-py3-none-any.whl.
File metadata
- Download URL: ghagen-0.3.1-py3-none-any.whl
- Upload date:
- Size: 107.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d885b09eec1742b6def16da01c8205e28bea2f24ce230b2ba393b6bda96d9536
|
|
| MD5 |
7496e808954ac754ecb0a899932d9c84
|
|
| BLAKE2b-256 |
83b1de0e19d66271a68a4fee88fe0e731834ae9566a34750dcd79adf887ab146
|
Provenance
The following attestation bundles were made for ghagen-0.3.1-py3-none-any.whl:
Publisher:
release.yml on nathanjordan/ghagen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ghagen-0.3.1-py3-none-any.whl -
Subject digest:
d885b09eec1742b6def16da01c8205e28bea2f24ce230b2ba393b6bda96d9536 - Sigstore transparency entry: 1292896074
- Sigstore integration time:
-
Permalink:
nathanjordan/ghagen@0139079eb2126a62a0274171f6a5376a047c5623 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nathanjordan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0139079eb2126a62a0274171f6a5376a047c5623 -
Trigger Event:
push
-
Statement type: