Generate GitHub Actions workflow YAML from Python code
Project description
ghagen
Generate GitHub Actions workflows from Python code.
Install
pip install ghagen
Example
from ghagen import Workflow, Job, Step, On, App
from ghagen.models.trigger import PushTrigger, PRTrigger
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(outdir=".github/workflows")
app.add(workflow, filename="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 - CLI —
ghagen synthgenerates YAML,ghagen checkverifies freshness in CI,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
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.2.1.tar.gz.
File metadata
- Download URL: ghagen-0.2.1.tar.gz
- Upload date:
- Size: 67.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
799c5947a2d2f321cf25754ea737d8d5e42a19c8c47fb93c970f8e5dcb94ff17
|
|
| MD5 |
3cbb7cefa81bf3a0e1b23ac432ac16de
|
|
| BLAKE2b-256 |
aa33cefc4598f857278ff9dfae762bdcbf92a830ad556340a1cad5c332b3bca5
|
Provenance
The following attestation bundles were made for ghagen-0.2.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.2.1.tar.gz -
Subject digest:
799c5947a2d2f321cf25754ea737d8d5e42a19c8c47fb93c970f8e5dcb94ff17 - Sigstore transparency entry: 1246112942
- Sigstore integration time:
-
Permalink:
nathanjordan/ghagen@066937e0663558bc5faea81effe47062a70301d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nathanjordan
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@066937e0663558bc5faea81effe47062a70301d4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ghagen-0.2.1-py3-none-any.whl.
File metadata
- Download URL: ghagen-0.2.1-py3-none-any.whl
- Upload date:
- Size: 53.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ca00db3d46f9f33f11b19f8535689fe2676d405795b8a74fbc506db6eb1ca53
|
|
| MD5 |
fe4bdbd3012b5047c266a227f98c79d4
|
|
| BLAKE2b-256 |
b2b896046bba7f9318dc573bfad77619944c5a501f8f4b58a1c9669e3c6b0f75
|
Provenance
The following attestation bundles were made for ghagen-0.2.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.2.1-py3-none-any.whl -
Subject digest:
1ca00db3d46f9f33f11b19f8535689fe2676d405795b8a74fbc506db6eb1ca53 - Sigstore transparency entry: 1246112962
- Sigstore integration time:
-
Permalink:
nathanjordan/ghagen@066937e0663558bc5faea81effe47062a70301d4 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nathanjordan
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@066937e0663558bc5faea81effe47062a70301d4 -
Trigger Event:
push
-
Statement type: