auto_label_prs.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. - 'testing/**'
  59. - 'toolchain/**'
  60. utilities:
  61. - 'utils/**'
  62. - id: documentation
  63. if: steps.filter.outputs.documentation == 'true'
  64. run: |
  65. gh pr edit "${PR}" --add-label "documentation"
  66. env:
  67. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  68. PR: ${{ github.event.pull_request.html_url }}
  69. - id: explorer
  70. if: steps.filter.outputs.explorer == 'true'
  71. run: |
  72. gh pr edit "${PR}" --add-label "explorer"
  73. env:
  74. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  75. PR: ${{ github.event.pull_request.html_url }}
  76. - id: infrastructure
  77. if: steps.filter.outputs.infrastructure == 'true'
  78. run: |
  79. gh pr edit "${PR}" --add-label "infrastructure"
  80. env:
  81. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  82. PR: ${{ github.event.pull_request.html_url }}
  83. - id: proposal
  84. if: steps.filter.outputs.proposal == 'true'
  85. run: |
  86. gh pr edit "${PR}" --add-label "proposal"
  87. env:
  88. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  89. PR: ${{ github.event.pull_request.html_url }}
  90. - id: toolchain
  91. if: steps.filter.outputs.toolchain == 'true'
  92. run: |
  93. gh pr edit "${PR}" --add-label "toolchain"
  94. env:
  95. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  96. PR: ${{ github.event.pull_request.html_url }}
  97. - id: utilities
  98. if: steps.filter.outputs.utilities == 'true'
  99. run: |
  100. gh pr edit "${PR}" --add-label "utilities"
  101. env:
  102. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  103. PR: ${{ github.event.pull_request.html_url }}
  104. # Note that this is not a path-based label, but an *author* based label,
  105. # and it applies orthogonally to the others.
  106. - id: automated
  107. if:
  108. contains(fromJSON('["CarbonInfraBot", "dependabot"]'),
  109. github.event.pull_request.user.login)
  110. run: |
  111. gh pr edit "${PR}" --add-label "automated"
  112. env:
  113. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  114. PR: ${{ github.event.pull_request.html_url }}