ci: add GitHub Action to auto-generate OpenAPI SDK types
Adds workflow that triggers on server code changes to: - Export OpenAPI spec from NestJS Swagger module - Generate TypeScript types with openapi-typescript - Build the SDK package - Create PR with changes if any exist Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
name: Generate OpenAPI SDK Types
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
paths:
|
||||
- 'packages/server/src/**/*.ts'
|
||||
- 'packages/server/src/**/*.dto.ts'
|
||||
- '!packages/server/src/**/*.spec.ts'
|
||||
- '!packages/server/src/**/*.test.ts'
|
||||
workflow_dispatch:
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: 'bash'
|
||||
|
||||
jobs:
|
||||
generate-openapi:
|
||||
name: Generate OpenAPI and SDK Types
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Generate OpenAPI spec and SDK types
|
||||
run: pnpm run generate:sdk-types
|
||||
|
||||
- name: Check for changes
|
||||
id: check-changes
|
||||
run: |
|
||||
if git diff --quiet shared/sdk-ts/; then
|
||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Create Pull Request
|
||||
if: steps.check-changes.outputs.has_changes == 'true'
|
||||
uses: peter-evans/create-pull-request@v6
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
commit-message: 'chore(sdk): update OpenAPI spec and generated types'
|
||||
title: 'chore(sdk): update OpenAPI spec and generated types'
|
||||
body: |
|
||||
## Summary
|
||||
Automated update of OpenAPI specification and generated TypeScript SDK types.
|
||||
|
||||
This PR was automatically generated by the `generate-openapi.yml` workflow due to server code changes.
|
||||
|
||||
## Changes
|
||||
- Updated `shared/sdk-ts/openapi.json`
|
||||
- Regenerated `shared/sdk-ts/src/schema.ts`
|
||||
|
||||
## Test plan
|
||||
- [ ] Verify the generated types compile correctly
|
||||
- [ ] Check that no breaking changes were introduced to the API types
|
||||
branch: chore/update-openapi-sdk-types
|
||||
base: ${{ github.ref_name }}
|
||||
labels: |
|
||||
automated
|
||||
sdk
|
||||
delete-branch: true
|
||||
Reference in New Issue
Block a user