generate.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. name: generate
  2. on:
  3. push:
  4. branches-ignore:
  5. - production
  6. pull_request:
  7. branches-ignore:
  8. - production
  9. workflow_dispatch:
  10. jobs:
  11. generate:
  12. runs-on: blacksmith-4vcpu-ubuntu-2404
  13. permissions:
  14. contents: write
  15. pull-requests: write
  16. steps:
  17. - name: Checkout repository
  18. uses: actions/checkout@v4
  19. with:
  20. token: ${{ secrets.GITHUB_TOKEN }}
  21. repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
  22. ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
  23. - name: Setup Bun
  24. uses: ./.github/actions/setup-bun
  25. - name: Generate
  26. run: ./script/generate.ts
  27. - name: Commit and push
  28. run: |
  29. if [ -z "$(git status --porcelain)" ]; then
  30. echo "No changes to commit"
  31. exit 0
  32. fi
  33. git config --local user.email "[email protected]"
  34. git config --local user.name "GitHub Action"
  35. git add -A
  36. git commit -m "chore: generate"
  37. if ! git push origin HEAD:${{ github.event.pull_request.head.ref || github.ref_name }} --no-verify; then
  38. echo ""
  39. echo "============================================"
  40. echo "Failed to push generated code."
  41. echo "Please run locally and push:"
  42. echo ""
  43. echo " ./script/generate.ts"
  44. echo " git add -A && git commit -m \"chore: generate\" && git push"
  45. echo ""
  46. echo "============================================"
  47. exit 1
  48. fi