| # Licensed to the Apache Software Foundation (ASF) under one or more |
| # contributor license agreements. See the NOTICE file distributed with |
| # this work for additional information regarding copyright ownership. |
| # The ASF licenses this file to You under the Apache License, Version 2.0 |
| # (the "License"); you may not use this file except in compliance with |
| # the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| # This workflow applies labels for PRs targeted at feature branches. |
| |
| name: label-pull-requests |
| |
| on: |
| workflow_call: |
| # allow running the workflow manually from GitHub UI |
| workflow_dispatch: |
| |
| jobs: |
| labeler: |
| permissions: |
| contents: read |
| pull-requests: write |
| runs-on: ubuntu-slim |
| strategy: |
| matrix: |
| include: |
| # branch -> label rules |
| - branch: HDDS-14496-zdu |
| label: zdu |
| fail-fast: false |
| steps: |
| - name: "Checkout project" # required for `gh` CLI |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| with: |
| persist-credentials: false |
| sparse-checkout: | |
| .github |
| - name: "Add label ${{ matrix.label }} to PRs for ${{ matrix.branch }}" |
| run: | |
| gh pr list --base "$BRANCH" --search "-label:$LABEL" --json number --jq '.[].number' \ |
| | xargs --max-args 1 --no-run-if-empty gh pr edit --add-label "$LABEL" |
| env: |
| # use variables to sanitize input |
| BRANCH: ${{ matrix.branch }} |
| LABEL: ${{ matrix.label }} |
| GH_TOKEN: ${{ github.token }} |