contributors.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: Contributors
  2. on:
  3. pull_request_target:
  4. types: [closed]
  5. branches: [main, master]
  6. workflow_dispatch:
  7. inputs:
  8. login:
  9. description: GitHub username to add
  10. required: true
  11. type: string
  12. contributions:
  13. description: Comma-separated contribution types
  14. required: false
  15. default: code
  16. type: string
  17. permissions:
  18. contents: write
  19. pull-requests: read
  20. jobs:
  21. add-contributor:
  22. if: >-
  23. github.event_name == 'workflow_dispatch' ||
  24. (github.event.pull_request.merged == true &&
  25. github.event.pull_request.user.type != 'Bot')
  26. runs-on: ubuntu-latest
  27. steps:
  28. - name: Checkout code
  29. uses: actions/checkout@v4
  30. with:
  31. token: ${{ secrets.GITHUB_TOKEN }}
  32. ref: ${{ github.event_name == 'workflow_dispatch' && github.event.repository.default_branch || github.event.pull_request.base.ref }}
  33. - name: Setup Bun
  34. uses: oven-sh/setup-bun@v2
  35. with:
  36. bun-version: latest
  37. - name: Install dependencies
  38. run: bun install --frozen-lockfile
  39. - name: Add contributor
  40. env:
  41. CONTRIBUTOR_LOGIN: ${{ github.event_name == 'workflow_dispatch' && inputs.login || github.event.pull_request.user.login }}
  42. CONTRIBUTION_TYPES: ${{ github.event_name == 'workflow_dispatch' && inputs.contributions || 'code' }}
  43. run: bunx all-contributors add "$CONTRIBUTOR_LOGIN" "$CONTRIBUTION_TYPES"
  44. - name: Commit contributors update
  45. uses: stefanzweifel/git-auto-commit-action@v5
  46. with:
  47. commit_message: "docs: update contributors [skip ci]"
  48. file_pattern: ".all-contributorsrc README.md"
  49. branch: ${{ github.event_name == 'workflow_dispatch' && github.event.repository.default_branch || github.event.pull_request.base.ref }}