auto_label_prs.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
  16. with:
  17. disable-sudo: true
  18. egress-policy: block
  19. # prettier-ignore
  20. allowed-endpoints: >
  21. api.github.com:443
  22. - id: filter
  23. uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  24. with:
  25. filters: |
  26. documentation:
  27. - '*.md'
  28. - 'docs/**'
  29. - 'examples/**'
  30. - 'third_party/examples/**'
  31. explorer:
  32. - 'explorer/**'
  33. - 'installers/**'
  34. infrastructure:
  35. - '*.bzl'
  36. - '*.cfg'
  37. - '*.toml'
  38. - '.*'
  39. - '.*/**'
  40. - 'BUILD'
  41. - 'MODULE.*'
  42. - 'WORKSPACE'
  43. - 'bazel/**'
  44. - 'github_tools/**'
  45. - 'proposal/scripts/**'
  46. - 'scripts/**'
  47. # Here we only want the `proposal` label when a *new* file is added
  48. # directly in this directory. We use `added` and a single level glob
  49. # to achieve that.
  50. proposal:
  51. - added: 'proposals/*'
  52. # We include common, shared code into the toolchain label for
  53. # convenience. Essentially, this is everything we intend to ship as
  54. # part of the reference implementation of the language.
  55. toolchain:
  56. - 'common/**'
  57. - 'core/**'
  58. - 'language_server/**'
  59. - 'testing/**'
  60. - 'toolchain/**'
  61. utilities:
  62. - 'utils/**'
  63. - id: documentation
  64. if: steps.filter.outputs.documentation == 'true'
  65. run: |
  66. gh pr edit "${PR}" --add-label "documentation"
  67. env:
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. PR: ${{ github.event.pull_request.html_url }}
  70. - id: explorer
  71. if: steps.filter.outputs.explorer == 'true'
  72. run: |
  73. gh pr edit "${PR}" --add-label "explorer"
  74. env:
  75. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  76. PR: ${{ github.event.pull_request.html_url }}
  77. - id: infrastructure
  78. if: steps.filter.outputs.infrastructure == 'true'
  79. run: |
  80. gh pr edit "${PR}" --add-label "infrastructure"
  81. env:
  82. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  83. PR: ${{ github.event.pull_request.html_url }}
  84. - id: proposal
  85. if: steps.filter.outputs.proposal == 'true'
  86. run: |
  87. gh pr edit "${PR}" --add-label "proposal"
  88. env:
  89. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  90. PR: ${{ github.event.pull_request.html_url }}
  91. - id: toolchain
  92. if: steps.filter.outputs.toolchain == 'true'
  93. run: |
  94. gh pr edit "${PR}" --add-label "toolchain"
  95. env:
  96. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  97. PR: ${{ github.event.pull_request.html_url }}
  98. - id: utilities
  99. if: steps.filter.outputs.utilities == 'true'
  100. run: |
  101. gh pr edit "${PR}" --add-label "utilities"
  102. env:
  103. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  104. PR: ${{ github.event.pull_request.html_url }}
  105. # Note that this is not a path-based label, but an *author* based label,
  106. # and it applies orthogonally to the others.
  107. - id: automated
  108. if:
  109. contains(fromJSON('["CarbonInfraBot", "dependabot"]'),
  110. github.event.pull_request.user.login)
  111. run: |
  112. gh pr edit "${PR}" --add-label "automated"
  113. env:
  114. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  115. PR: ${{ github.event.pull_request.html_url }}