|
2 | 2 | name: Generate Client
|
3 | 3 |
|
4 | 4 | on:
|
5 |
| - pull_request: |
6 |
| - types: [opened, synchronize] |
7 | 5 | push:
|
8 | 6 | branches: [main]
|
| 7 | + pull_request: |
| 8 | + types: [closed] |
9 | 9 |
|
10 | 10 | permissions:
|
11 | 11 | contents: write
|
12 | 12 |
|
13 | 13 | jobs:
|
14 | 14 | generate-client:
|
| 15 | + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) |
15 | 16 | runs-on: ubuntu-latest
|
16 | 17 |
|
17 | 18 | steps:
|
@@ -73,34 +74,32 @@ jobs:
|
73 | 74 | POSTHOG_HOST: ""
|
74 | 75 | VIRTUAL_ENV: .venv
|
75 | 76 |
|
76 |
| - - name: Configure Git User |
77 |
| - run: | |
78 |
| - git config --global user.email "[email protected]" |
79 |
| - git config --global user.name "GitHub Actions" |
80 |
| -
|
81 | 77 | - name: Stage Generated Files
|
82 | 78 | run: |
|
83 | 79 | git add frontend/app/openapi-client
|
84 | 80 | git add admin/src/client
|
85 | 81 |
|
86 |
| - # 7. Handle Changes for Same-Repo Events (Push/PR from same repo) |
87 |
| - - name: Commit and Push Changes (Same Repo) |
88 |
| - # Run only if it's NOT a PR from a fork |
89 |
| - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) |
| 82 | + auto-commit-push: |
| 83 | + needs: generate-client |
| 84 | + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Checkout Code |
| 88 | + uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - name: Setup Git User |
90 | 91 | run: |
|
91 |
| - if ! git diff --staged --quiet; then |
92 |
| - echo "✅ Changes detected in generated client. Committing and pushing..." |
93 |
| - git pull --rebase origin ${{ github.head_ref || github.ref_name }} |
94 |
| - if ! git diff --quiet || ! git diff --staged --quiet; then |
95 |
| - git commit -a -m "ci: ✨ Autogenerate frontend client" |
96 |
| - git push origin HEAD:${{ github.head_ref || github.ref_name }} |
97 |
| - else |
98 |
| - echo "✅ No changes to commit after rebase." |
99 |
| - git push origin HEAD:${{ github.head_ref || github.ref_name }} |
100 |
| - else |
101 |
| - echo "✅ No changes detected in generated client." |
| 92 | + git config --local user.email "[email protected]" |
| 93 | + git config --local user.name "kubbot" |
| 94 | + git remote set-url origin https://${{ secrets.BOT_GITHUB_TOKEN }}@github.com/${{ github.repository }} |
| 95 | +
|
| 96 | + - name: Commit and Push Changes (Auto Green) |
| 97 | + run: | |
| 98 | + git pull --rebase |
| 99 | + local_time=$(date -u -d "$(date -u)" "+%Y-%m-%d %H:%M:%S" -d "8 hours") |
| 100 | + git commit --allow-empty -a -s -m "ci: ✨ Autogenerate frontend client ($local_time)" |
| 101 | + git push |
102 | 102 | env:
|
103 |
| - # GITHUB_TOKEN has write permissions for same-repo events by default |
104 | 103 | GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
|
105 | 104 |
|
106 | 105 | # 8. Handle Changes for Fork PRs (Warn, Don't Fail)
|
|
0 commit comments