Skip to content

Commit 5c3bea4

Browse files
committed
Generate JSON Schema & push to GH Pages
1 parent edc6450 commit 5c3bea4

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

.github/workflows/docs.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python 3.11
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: "3.11"
22+
- name: Install dependencies
23+
run: |
24+
pip install uv
25+
uv sync
26+
27+
- name: Build schema
28+
run: |
29+
mkdir dist
30+
uv run deploy schema -o dist/schema.json
31+
32+
- name: Upload static files as artifact
33+
uses: actions/upload-pages-artifact@v3
34+
with:
35+
path: dist/
36+
37+
deploy:
38+
environment:
39+
name: github-pages
40+
url: ${{ steps.deployment.outputs.page_url }}
41+
runs-on: ubuntu-latest
42+
needs: build
43+
44+
permissions:
45+
id-token: write
46+
pages: write
47+
48+
steps:
49+
- name: Deploy to GitHub Pages
50+
uses: actions/deploy-pages@v4

src/deploy/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import click
44

55
from deploy.commands.build import subcommand_build
6+
from deploy.commands.schema import subcommand_schema
67
from deploy.commands.sync import subcommand_sync
78
from deploy.commands.test import subcommand_test
89

@@ -13,6 +14,7 @@ def cli() -> None:
1314

1415

1516
cli.add_command(subcommand_build)
17+
cli.add_command(subcommand_schema)
1618
cli.add_command(subcommand_sync)
1719
cli.add_command(subcommand_test)
1820

src/deploy/commands/schema.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import annotations
2+
from pathlib import Path
3+
4+
import click
5+
import json
6+
from deploy.config import Config
7+
8+
9+
@click.command("schema", help="Generate JSON Schema")
10+
@click.option("-o", "--output", default="/dev/stdout", type=Path, help="Output file")
11+
def subcommand_schema(output: Path) -> None:
12+
with open(output, "w") as f:
13+
json.dump(Config.model_json_schema(), f)
14+
f.write("\n")

0 commit comments

Comments
 (0)