1212 contents : write
1313 runs-on : ubuntu-latest
1414 steps :
15+ # For PRs from forks
1516 - uses : actions/checkout@v4
17+ # For PRs from the same repo
18+ - uses : actions/checkout@v4
19+ if : ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
1620 with :
1721 ref : ${{ github.head_ref }}
1822 token : ${{ secrets.FULL_STACK_FASTAPI_TEMPLATE_REPO_TOKEN }}
@@ -21,29 +25,33 @@ jobs:
2125 node-version : lts/*
2226 - uses : actions/setup-python@v5
2327 with :
24- python-version : ' 3.10'
28+ python-version : " 3.10"
29+ - name : Install uv
30+ uses : astral-sh/setup-uv@v2
31+ with :
32+ version : " 0.4.15"
33+ enable-cache : true
2534 - name : Install dependencies
2635 run : npm ci
2736 working-directory : frontend
28- - run : pip install ./backend
29- - run : bash scripts/generate-client.sh
30- - name : Commit changes
37+ - run : uv sync
38+ working-directory : backend
39+ - run : uv run bash scripts/generate-client.sh
40+ env :
41+ VIRTUAL_ENV : backend/.venv
42+ - name : Add changes to git
3143 run : |
3244 git config --local user.email "[email protected] " 3345 git config --local user.name "github-actions"
3446 git add frontend/src/client
47+ # Same repo PRs
48+ - name : Push changes
49+ if : ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
50+ run : |
3551 git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client"
3652 git push
37-
38- # https://github.com/marketplace/actions/alls-green#why
39- generate-client-alls-green : # This job does nothing and is only used for the branch protection
40- if : always()
41- needs :
42- - generate-client
43- runs-on : ubuntu-latest
44- steps :
45- - name : Decide whether the needed jobs succeeded or failed
46- uses : re-actors/alls-green@release/v1
47- with :
48- jobs : ${{ toJSON(needs) }}
49-
53+ # Fork PRs
54+ - name : Check changes
55+ if : ( github.event_name == 'pull_request' && github.secret_source != 'Actions' )
56+ run : |
57+ git diff --staged --quiet || (echo "Changes detected in generated client, run scripts/generate-client.sh and commit the changes" && exit 1)
0 commit comments