auto_label_prs.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. infrastructure:
  32. - '*.bzl'
  33. - '*.cfg'
  34. - '*.toml'
  35. - '.*'
  36. - '.*/**'
  37. - 'BUILD'
  38. - 'MODULE.*'
  39. - 'WORKSPACE'
  40. - 'bazel/**'
  41. - 'github_tools/**'
  42. - 'proposal/scripts/**'
  43. - 'scripts/**'
  44. # Here we only want the `proposal` label when a *new* file is added
  45. # directly in this directory. We use `added` and a single level glob
  46. # to achieve that.
  47. proposal:
  48. - added: 'proposals/*'
  49. # We include common, shared code into the toolchain label for
  50. # convenience. Essentially, this is everything we intend to ship as
  51. # part of the reference implementation of the language.
  52. toolchain:
  53. - 'common/**'
  54. - 'core/**'
  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: infrastructure
  67. if: steps.filter.outputs.infrastructure == 'true'
  68. run: |
  69. gh pr edit "${PR}" --add-label "infrastructure"
  70. env:
  71. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  72. PR: ${{ github.event.pull_request.html_url }}
  73. - id: proposal
  74. if: steps.filter.outputs.proposal == 'true'
  75. run: |
  76. gh pr edit "${PR}" --add-label "proposal"
  77. env:
  78. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  79. PR: ${{ github.event.pull_request.html_url }}
  80. - id: toolchain
  81. if: steps.filter.outputs.toolchain == 'true'
  82. run: |
  83. gh pr edit "${PR}" --add-label "toolchain"
  84. env:
  85. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  86. PR: ${{ github.event.pull_request.html_url }}
  87. - id: utilities
  88. if: steps.filter.outputs.utilities == 'true'
  89. run: |
  90. gh pr edit "${PR}" --add-label "utilities"
  91. env:
  92. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  93. PR: ${{ github.event.pull_request.html_url }}
  94. # Note that this is not a path-based label, but an *author* based label,
  95. # and it applies orthogonally to the others.
  96. - id: automated
  97. if:
  98. contains(fromJSON('["CarbonInfraBot", "dependabot"]'),
  99. github.event.pull_request.user.login)
  100. run: |
  101. gh pr edit "${PR}" --add-label "automated"
  102. env:
  103. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  104. PR: ${{ github.event.pull_request.html_url }}