generate.yml 1.6 KB

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