File: label_pr.yml

package info (click to toggle)
commitizen 4.11.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,912 kB
  • sloc: python: 17,743; makefile: 15
file content (47 lines) | stat: -rw-r--r-- 1,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "Label Pull Request"
on:
- pull_request_target

jobs:
  label-pr:
    permissions:
      contents: read
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
      with:
        sparse-checkout: |
          .github/labeler.yml
        sparse-checkout-cone-mode: false
    - uses: actions/labeler@v6
      with:
        configuration-path: .github/labeler.yml
    - name: Label based on PR title
      uses: actions/github-script@v8
      with:
        script: |
          const title = context.payload.pull_request.title.toLowerCase();
          const labels = [];

          if (title.includes("fix") || title.includes("bug")) {
            labels.push("type: bug");
          }
          if (title.includes("feat")) {
            labels.push("type: feature");
          }
          if (title.includes("doc")) {
            labels.push("type: documentation");
          }
          if (title.includes("refactor")) {
            labels.push("type: refactor");
          }

          if (labels.length > 0) {
            await github.rest.issues.addLabels({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.payload.pull_request.number,
              labels
            });
          }