🔨 Generate frontend SDK on pre-commit, remove custom workflow (#2111)

This commit is contained in:
Sebastián Ramírez
2026-01-22 11:10:01 -08:00
committed by GitHub
parent da603ebaac
commit 0564d65041
4 changed files with 10 additions and 56 deletions

View File

@@ -1,53 +0,0 @@
name: Generate Client
on:
pull_request:
types:
- opened
- synchronize
jobs:
generate-client:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
# For PRs from forks
- uses: actions/checkout@v6
# For PRs from the same repo
- uses: actions/checkout@v6
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }}
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install dependencies
run: bun ci
- run: uv sync
working-directory: backend
- run: bash scripts/generate-client.sh
env:
SECRET_KEY: just-for-generating-client
POSTGRES_PASSWORD: just-for-generating-client
FIRST_SUPERUSER_PASSWORD: just-for-generating-client
- name: Add changes to git
run: |
git config --local user.email "github-actions@github.com"
git config --local user.name "github-actions"
git add frontend/src/client
# Same repo PRs
- name: Push changes
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
run: |
git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client"
git push
# Fork PRs
- name: Check changes
if: ( github.event_name == 'pull_request' && github.secret_source != 'Actions' )
run: |
git diff --staged --quiet || (echo "Changes detected in generated client, run scripts/generate-client.sh and commit the changes" && exit 1)

View File

@@ -66,13 +66,13 @@ jobs:
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "🎨 Auto format"
git commit -m "🎨 Auto format and update with pre-commit"
git push
fi
- uses: pre-commit-ci/lite-action@v1.1.0
if: env.HAS_SECRETS == 'false'
with:
msg: 🎨 Auto format
msg: 🎨 Auto format and update with pre-commit
- name: Error out on pre-commit errors
if: steps.precommit.outcome == 'failure'
run: exit 1

View File

@@ -39,3 +39,10 @@ repos:
require_serial: true
language: unsupported
types: [python]
- id: generate-frontend-sdk
name: Generate Frontend SDK
entry: bash ./scripts/generate-client.sh
pass_filenames: false
language: unsupported
files: ^backend/.*$|^scripts/generate-client\.sh$

View File

@@ -4,7 +4,7 @@
"workspaces": [
"frontend"
],
"scripts": {
"scripts": {
"dev": "bun run --filter frontend dev",
"lint": "bun run --filter frontend lint",
"test": "bun run --filter frontend test",