labeler.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. name: "Pull Request Labeler"
  2. on:
  3. pull_request_target:
  4. types: [opened]
  5. jobs:
  6. triage:
  7. runs-on: ubuntu-latest
  8. permissions:
  9. contents: read
  10. pull-requests: write
  11. steps:
  12. - uses: actions/labeler@main
  13. with:
  14. repo-token: "${{ secrets.GITHUB_TOKEN }}"
  15. sync-labels: ""
  16. type-scope:
  17. runs-on: ubuntu-latest
  18. permissions:
  19. contents: write
  20. pull-requests: write
  21. env:
  22. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  23. GH_REPO: ${{ github.repository }}
  24. PR_NUMBER: ${{ github.event.pull_request.number }}
  25. PR_TITLE: ${{ github.event.pull_request.title }}
  26. steps:
  27. - name: "Extract commit type and add as label"
  28. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true
  29. - name: "Extract commit scope and add as label"
  30. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true
  31. - name: "Extract if the PR is a breaking change and add it as label"
  32. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true
  33. request-reviewer:
  34. if: github.event.pull_request.state == 'open' && github.event.pull_request.draft == false
  35. runs-on: ubuntu-latest
  36. needs: ["triage", "type-scope"]
  37. permissions:
  38. pull-requests: write
  39. steps:
  40. - uses: actions/checkout@v2
  41. - name: 'Request reviewers'
  42. uses: actions/github-script@v6
  43. with:
  44. script: |
  45. const script = require('./.github/scripts/reviews.js')
  46. await script({github, context})