labeler_pr.yml (1894B)
1 name: "labeler: PR" 2 on: 3 pull_request_target: 4 types: [opened] 5 jobs: 6 changed-files: 7 runs-on: ubuntu-latest 8 permissions: 9 contents: read 10 pull-requests: write 11 steps: 12 - uses: actions/checkout@v6 13 - uses: actions/labeler@v6 14 with: 15 configuration-path: .github/scripts/labeler_configuration.yml 16 17 type-scope: 18 needs: changed-files 19 runs-on: ubuntu-latest 20 permissions: 21 contents: write 22 pull-requests: write 23 env: 24 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 GH_REPO: ${{ github.repository }} 26 PR_NUMBER: ${{ github.event.pull_request.number }} 27 PR_TITLE: ${{ github.event.pull_request.title }} 28 steps: 29 - name: "Extract commit type and add as label" 30 run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true 31 - name: "Extract commit scope and add as label" 32 run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true 33 - name: "Extract if the PR is a breaking change and add it as label" 34 run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true 35 36 target-release: 37 needs: ["changed-files", "type-scope"] 38 runs-on: ubuntu-latest 39 permissions: 40 pull-requests: write 41 steps: 42 - if: startsWith(github.base_ref, 'release') 43 uses: actions/github-script@v8 44 with: 45 script: | 46 github.rest.issues.addLabels({ 47 issue_number: context.issue.number, 48 owner: context.repo.owner, 49 repo: context.repo.repo, 50 labels: ['target:release'] 51 }) 52 53 request-reviewer: 54 needs: ["changed-files", "type-scope", "target-release"] 55 permissions: 56 pull-requests: write 57 uses: ./.github/workflows/reviewers_add.yml