labeler_pr.yml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. name: "labeler: PR"
  2. on:
  3. pull_request_target:
  4. types: [opened]
  5. jobs:
  6. changed-files:
  7. runs-on: ubuntu-latest
  8. permissions:
  9. contents: read
  10. pull-requests: write
  11. steps:
  12. - uses: actions/checkout@v4
  13. - uses: actions/labeler@v5
  14. with:
  15. configuration-path: .github/scripts/labeler_configuration.yml
  16. type-scope:
  17. needs: changed-files
  18. runs-on: ubuntu-latest
  19. permissions:
  20. contents: write
  21. pull-requests: write
  22. env:
  23. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  24. GH_REPO: ${{ github.repository }}
  25. PR_NUMBER: ${{ github.event.pull_request.number }}
  26. PR_TITLE: ${{ github.event.pull_request.title }}
  27. steps:
  28. - name: "Extract commit type and add as label"
  29. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true
  30. - name: "Extract commit scope and add as label"
  31. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true
  32. - name: "Extract if the PR is a breaking change and add it as label"
  33. run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true
  34. target-release:
  35. needs: ["changed-files", "type-scope"]
  36. runs-on: ubuntu-latest
  37. permissions:
  38. pull-requests: write
  39. steps:
  40. - if: startsWith(github.base_ref, 'release')
  41. uses: actions/github-script@v7
  42. with:
  43. script: |
  44. github.rest.issues.addLabels({
  45. issue_number: context.issue.number,
  46. owner: context.repo.owner,
  47. repo: context.repo.repo,
  48. labels: ['target:release']
  49. })
  50. request-reviewer:
  51. needs: ["changed-files", "type-scope", "target-release"]
  52. permissions:
  53. pull-requests: write
  54. uses: ./.github/workflows/reviewers_add.yml