auto_label_prs.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. # TODO: `--repo carbon-language/carbon-lang` is a temporary workaround for:
  11. # https://github.com/cli/cli/issues/11055
  12. # Once a later version is released on runners, maybe August 2025, we should be
  13. # able to remove the extra flag.
  14. jobs:
  15. set_labels:
  16. runs-on: ubuntu-latest
  17. steps:
  18. - name: Harden Runner
  19. uses: step-security/harden-runner@58077d3c7e43986b6b15fba718e8ea69e387dfcc # v2.15.1
  20. with:
  21. disable-sudo: true
  22. egress-policy: block
  23. # prettier-ignore
  24. allowed-endpoints: >
  25. api.github.com:443
  26. - id: filter
  27. uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
  28. with:
  29. filters: |
  30. documentation:
  31. - '*.md'
  32. - 'docs/**'
  33. - 'examples/**'
  34. - 'third_party/examples/**'
  35. infrastructure:
  36. - '*.bzl'
  37. - '*.cfg'
  38. - '*.toml'
  39. - '.*'
  40. - '.*/**'
  41. - 'BUILD'
  42. - 'MODULE.*'
  43. - 'WORKSPACE'
  44. - 'bazel/**'
  45. - 'github_tools/**'
  46. - 'proposal/scripts/**'
  47. - 'scripts/**'
  48. # Here we only want the `proposal` label when a *new* file is added
  49. # directly in this directory. We use `added` and a single level glob
  50. # to achieve that.
  51. proposal:
  52. - added: 'proposals/*'
  53. # We include common, shared code into the toolchain label for
  54. # convenience. Essentially, this is everything we intend to ship as
  55. # part of the reference implementation of the language.
  56. toolchain:
  57. - 'common/**'
  58. - 'core/**'
  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" --repo carbon-language/carbon-lang
  67. env:
  68. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  69. PR: ${{ github.event.pull_request.html_url }}
  70. - id: infrastructure
  71. if: steps.filter.outputs.infrastructure == 'true'
  72. run: |
  73. gh pr edit "${PR}" --add-label "infrastructure" --repo carbon-language/carbon-lang
  74. env:
  75. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  76. PR: ${{ github.event.pull_request.html_url }}
  77. - id: proposal
  78. if: steps.filter.outputs.proposal == 'true'
  79. run: |
  80. gh pr edit "${PR}" --add-label "proposal" --repo carbon-language/carbon-lang
  81. env:
  82. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  83. PR: ${{ github.event.pull_request.html_url }}
  84. - id: toolchain
  85. if: steps.filter.outputs.toolchain == 'true'
  86. run: |
  87. gh pr edit "${PR}" --add-label "toolchain" --repo carbon-language/carbon-lang
  88. env:
  89. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  90. PR: ${{ github.event.pull_request.html_url }}
  91. - id: utilities
  92. if: steps.filter.outputs.utilities == 'true'
  93. run: |
  94. gh pr edit "${PR}" --add-label "utilities" --repo carbon-language/carbon-lang
  95. env:
  96. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  97. PR: ${{ github.event.pull_request.html_url }}
  98. # Note that this is not a path-based label, but an *author* based label,
  99. # and it applies orthogonally to the others.
  100. - id: automated
  101. if:
  102. contains(fromJSON('["CarbonInfraBot", "dependabot"]'),
  103. github.event.pull_request.user.login)
  104. run: |
  105. gh pr edit "${PR}" --add-label "automated" --repo carbon-language/carbon-lang
  106. env:
  107. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  108. PR: ${{ github.event.pull_request.html_url }}