label_prs.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. # Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. # Exceptions. See /LICENSE for license information.
  3. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. name: 'Auto label PRs'
  5. on:
  6. pull_request_target:
  7. types: [opened, ready_for_review]
  8. permissions:
  9. pull-requests: write # For gh to edit labels.
  10. jobs:
  11. assign_reviewer:
  12. runs-on: ubuntu-latest
  13. steps:
  14. - name: Harden Runner
  15. uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0
  16. with:
  17. egress-policy: audit
  18. - id: filter
  19. uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  20. with:
  21. filters: |
  22. documentation:
  23. - '*.md'
  24. - 'docs/**'
  25. - 'examples/**'
  26. - 'third_party/examples/**'
  27. explorer:
  28. - 'explorer/**'
  29. - 'installers/**'
  30. infrastructure:
  31. - '*.bzl'
  32. - '*.cfg'
  33. - '*.toml'
  34. - '.*'
  35. - '.*/**'
  36. - 'BUILD'
  37. - 'MODULE.*'
  38. - 'WORKSPACE'
  39. - 'bazel/**'
  40. - 'github_tools/**'
  41. - 'proposal/scripts/**'
  42. - 'scripts/**'
  43. # Here we only want the `proposal` label when a *new* file is added
  44. # directly in this directory. We use `added` and a single level glob
  45. # to achieve that.
  46. proposal:
  47. - added: 'proposals/*'
  48. # We include common, shared code into the toolchain label for
  49. # convenience. Essentially, this is everything we intend to ship as
  50. # part of the reference implementation of the language.
  51. toolchain:
  52. - 'common/**'
  53. - 'core/**'
  54. - 'language_server/**'
  55. - 'testing/**'
  56. - 'toolchain/**'
  57. utilities:
  58. - 'utils/**'
  59. - id: documentation
  60. if: steps.filter.outputs.documentation == 'true'
  61. run: |
  62. gh pr edit "${PR}" --add-label "documentation"
  63. env:
  64. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  65. PR: ${{ github.event.pull_request.html_url }}
  66. - id: explorer
  67. if: steps.filter.outputs.explorer == 'true'
  68. run: |
  69. gh pr edit "${PR}" --add-label "explorer"
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. PR: ${{ github.event.pull_request.html_url }}
  73. - id: infrastructure
  74. if: steps.filter.outputs.infrastructure == 'true'
  75. run: |
  76. gh pr edit "${PR}" --add-label "infrastructure"
  77. env:
  78. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  79. PR: ${{ github.event.pull_request.html_url }}
  80. - id: proposal
  81. if: steps.filter.outputs.proposal == 'true'
  82. run: |
  83. gh pr edit "${PR}" --add-label "proposal"
  84. env:
  85. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. PR: ${{ github.event.pull_request.html_url }}
  87. - id: toolchain
  88. if: steps.filter.outputs.toolchain == 'true'
  89. run: |
  90. gh pr edit "${PR}" --add-label "toolchain"
  91. env:
  92. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  93. PR: ${{ github.event.pull_request.html_url }}
  94. - id: utilities
  95. if: steps.filter.outputs.utilities == 'true'
  96. run: |
  97. gh pr edit "${PR}" --add-label "utilities"
  98. env:
  99. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  100. PR: ${{ github.event.pull_request.html_url }}
  101. # Note that this is not a path-based label, but an *author* based label,
  102. # and it applies orthogonally to the others.
  103. - id: automated
  104. if:
  105. contains(fromJSON('["CarbonInfraBot", "dependabot"]'),
  106. github.event.pull_request.user.login)
  107. run: |
  108. gh pr edit "${PR}" --add-label "automated"
  109. env:
  110. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  111. PR: ${{ github.event.pull_request.html_url }}