Skip to content

Commit c297e9e

Browse files
authored
👷 Generate and commit client only on same repo PRs, on forks, show the error (#1376)
1 parent 7e5ca88 commit c297e9e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎.github/workflows/generate-client.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ jobs:
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 }}
@@ -35,10 +39,19 @@ jobs:
3539
- run: uv run bash scripts/generate-client.sh
3640
env:
3741
VIRTUAL_ENV: backend/.venv
38-
- name: Commit changes
42+
- name: Add changes to git
3943
run: |
4044
git config --local user.email "[email protected]"
4145
git config --local user.name "github-actions"
4246
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: |
4351
git diff --staged --quiet || git commit -m "✨ Autogenerate frontend client"
4452
git push
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"

0 commit comments

Comments
 (0)