generate.yml 1.6 KB

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