Skip to content

spec_updated

spec_updated #2

Workflow file for this run

name: Spec Check
on:
repository_dispatch:
types: [spec_updated]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
check-compatibility:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Download latest OpenAPI spec from monorepo
run: |
gh api repos/devhelmhq/mono/contents/docs/openapi/monitoring-api.json \
-H "Accept: application/vnd.github.raw+json" \
> docs/openapi/monitoring-api.json
env:
GH_TOKEN: ${{ secrets.MONOREPO_DISPATCH_TOKEN }}
- run: uv sync
- run: uv run pytest -v
- name: Regenerate types from spec
run: ./scripts/typegen.sh
- name: Check for type changes
id: diff
run: |
if git diff --quiet src/devhelm/_generated.py docs/openapi/; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Open PR with updated types
if: steps.diff.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
branch="chore/update-api-types-$(date +%Y%m%d%H%M%S)"
git checkout -b "$branch"
git add src/devhelm/_generated.py docs/openapi/monitoring-api.json
git commit -m "chore: update generated API types from latest spec"
git push -u origin "$branch"
gh pr create \
--title "chore: update generated API types" \
--body "Auto-generated from latest OpenAPI spec in the monorepo." \
--base main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report failure
if: failure()
run: |
gh issue create \
--title "API spec change broke Python SDK build" \
--body "The monorepo pushed a spec update that caused CI failures.\n\nWorkflow: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}