aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/labeler_pr.yml
blob: 5d402c3c03a6f4a800dd3e4d0f03d3c5874a950e (plain) (blame)
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
48
49
50
51
52
53
54
55
56
57
name: "labeler: PR"
on:
  pull_request_target:
    types: [opened]
jobs:
  changed-files:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
    - uses: actions/checkout@v4
    - uses: actions/labeler@v5
      with:
        configuration-path: .github/scripts/labeler_configuration.yml

  type-scope:
    needs: changed-files
    runs-on: ubuntu-latest
    permissions:
      contents: write
      pull-requests: write
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      GH_REPO: ${{ github.repository }}
      PR_NUMBER: ${{ github.event.pull_request.number }}
      PR_TITLE: ${{ github.event.pull_request.title }}
    steps:
    - name: "Extract commit type and add as label"
      run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|([[:alpha:]]+)(\(.*\))?!?:.*|\1|')" || true
    - name: "Extract commit scope and add as label"
      run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+\((.+)\)!?:.*|\1|')" || true
    - name: "Extract if the PR is a breaking change and add it as label"
      run: gh pr edit "$PR_NUMBER" --add-label "$(echo "$PR_TITLE" | sed -E 's|[[:alpha:]]+(\(.*\))?!:.*|breaking-change|')" || true

  target-release:
    needs: ["changed-files", "type-scope"]
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
    - if: startsWith(github.base_ref, 'release')
      uses: actions/github-script@v7
      with:
        script: |
          github.rest.issues.addLabels({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            labels: ['target:release']
          })

  request-reviewer:
    needs: ["changed-files", "type-scope", "target-release"]
    permissions:
      pull-requests: write
    uses: ./.github/workflows/reviewers_add.yml