🔨 Generate frontend SDK on pre-commit, remove custom workflow (#2111)
This commit is contained in:
committed by
GitHub
parent
da603ebaac
commit
0564d65041
53
.github/workflows/generate-client.yml
vendored
53
.github/workflows/generate-client.yml
vendored
@@ -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)
|
|
||||||
4
.github/workflows/pre-commit.yml
vendored
4
.github/workflows/pre-commit.yml
vendored
@@ -66,13 +66,13 @@ jobs:
|
|||||||
if git diff --staged --quiet; then
|
if git diff --staged --quiet; then
|
||||||
echo "No changes to commit"
|
echo "No changes to commit"
|
||||||
else
|
else
|
||||||
git commit -m "🎨 Auto format"
|
git commit -m "🎨 Auto format and update with pre-commit"
|
||||||
git push
|
git push
|
||||||
fi
|
fi
|
||||||
- uses: pre-commit-ci/lite-action@v1.1.0
|
- uses: pre-commit-ci/lite-action@v1.1.0
|
||||||
if: env.HAS_SECRETS == 'false'
|
if: env.HAS_SECRETS == 'false'
|
||||||
with:
|
with:
|
||||||
msg: 🎨 Auto format
|
msg: 🎨 Auto format and update with pre-commit
|
||||||
- name: Error out on pre-commit errors
|
- name: Error out on pre-commit errors
|
||||||
if: steps.precommit.outcome == 'failure'
|
if: steps.precommit.outcome == 'failure'
|
||||||
run: exit 1
|
run: exit 1
|
||||||
|
|||||||
@@ -39,3 +39,10 @@ repos:
|
|||||||
require_serial: true
|
require_serial: true
|
||||||
language: unsupported
|
language: unsupported
|
||||||
types: [python]
|
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$
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"workspaces": [
|
"workspaces": [
|
||||||
"frontend"
|
"frontend"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --filter frontend dev",
|
"dev": "bun run --filter frontend dev",
|
||||||
"lint": "bun run --filter frontend lint",
|
"lint": "bun run --filter frontend lint",
|
||||||
"test": "bun run --filter frontend test",
|
"test": "bun run --filter frontend test",
|
||||||
|
|||||||
Reference in New Issue
Block a user