|
| 1 | +--- |
| 2 | +# SPDX-FileCopyrightText: 2025 The Linux Foundation |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | + |
| 5 | +name: 'Autolabeler' |
| 6 | + |
| 7 | +# yamllint disable-line rule:truthy |
| 8 | +on: |
| 9 | + # pull_request is required for autolabeler |
| 10 | + pull_request: |
| 11 | + types: |
| 12 | + - opened |
| 13 | + - synchronize |
| 14 | + - reopened |
| 15 | + # pull_request_target is required for autolabeler on PRs from forks |
| 16 | + pull_request_target: |
| 17 | + types: |
| 18 | + - opened |
| 19 | + - synchronize |
| 20 | + - reopened |
| 21 | + |
| 22 | +permissions: {} |
| 23 | + |
| 24 | +concurrency: |
| 25 | + # yamllint disable-line rule:line-length |
| 26 | + group: ${{ format('al-{0}-pr-{1}', github.event_name, github.event.pull_request.number) }} |
| 27 | + cancel-in-progress: true |
| 28 | + |
| 29 | +jobs: |
| 30 | + autolabel: |
| 31 | + name: 'Autolabel PR' |
| 32 | + # Run on pull_request_target for forks, or pull_request for same-repo PRs |
| 33 | + # This prevents duplicate runs for same-repo PRs |
| 34 | + # yamllint disable rule:line-length |
| 35 | + if: > |
| 36 | + (github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.fork) || |
| 37 | + (github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) |
| 38 | + # yamllint enable rule:line-length |
| 39 | + # SECURITY: pull_request_target with write permissions is safe here because: |
| 40 | + # 1. This workflow does NOT checkout any code from the PR |
| 41 | + # 2. The workflow code itself runs from the base branch (not the fork) |
| 42 | + # 3. release-drafter only makes GitHub API calls (no code execution) |
| 43 | + # 4. pull_request_target is needed ONLY for autolabeling fork PRs |
| 44 | + permissions: |
| 45 | + # write permission is required for autolabeler |
| 46 | + pull-requests: write |
| 47 | + # read is sufficient; autolabeler does not create releases |
| 48 | + contents: read |
| 49 | + runs-on: 'ubuntu-latest' |
| 50 | + timeout-minutes: 3 |
| 51 | + steps: |
| 52 | + # Harden the runner used by this workflow |
| 53 | + # yamllint disable-line rule:line-length |
| 54 | + - uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 |
| 55 | + with: |
| 56 | + egress-policy: 'audit' |
| 57 | + |
| 58 | + # yamllint disable-line rule:line-length |
| 59 | + - uses: release-drafter/release-drafter/autolabeler@44a942e465867c7465b76aa808ddca6e0acae5da # v7.1.0 |
0 commit comments