|
| 1 | +name: Label, Assignee and Set PR Title |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + set-title: |
| 9 | + if: | |
| 10 | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + pull-requests: write |
| 14 | + steps: |
| 15 | + - uses: actions/github-script@v7 |
| 16 | + with: |
| 17 | + script: | |
| 18 | + const branch = context.payload.pull_request.head.ref; |
| 19 | + const [prefix, ...rest] = branch.split('-'); |
| 20 | + const title = `${prefix.charAt(0).toUpperCase() + prefix.slice(1)}: ${rest.join(' ')}`; |
| 21 | +
|
| 22 | + await github.rest.pulls.update({ |
| 23 | + owner: context.repo.owner, |
| 24 | + repo: context.repo.repo, |
| 25 | + pull_number: context.payload.pull_request.number, |
| 26 | + title, |
| 27 | + assignees: [context.repo.owner] |
| 28 | + }); |
| 29 | +
|
| 30 | + assign-owner: |
| 31 | + if: | |
| 32 | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) |
| 33 | + runs-on: ubuntu-latest |
| 34 | + permissions: |
| 35 | + pull-requests: write |
| 36 | + steps: |
| 37 | + - uses: actions-ecosystem/action-add-assignees@v1 |
| 38 | + with: |
| 39 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + assignees: ${{ github.repository_owner }} |
| 41 | + |
| 42 | + labels: |
| 43 | + if: | |
| 44 | + (github.event_name == 'pull_request' && github.event.pull_request.draft == false) |
| 45 | + runs-on: ubuntu-latest |
| 46 | + permissions: |
| 47 | + pull-requests: write |
| 48 | + issues: write |
| 49 | + steps: |
| 50 | + # Bugfix labels |
| 51 | + - if: startsWith(github.event.pull_request.head.ref, 'bugfix') || startsWith(github.event.pull_request.head.ref, 'fix') |
| 52 | + uses: actions-ecosystem/action-add-labels@v1 |
| 53 | + with: |
| 54 | + labels: | |
| 55 | + bug |
| 56 | + python |
| 57 | +
|
| 58 | + # Enhancement labels |
| 59 | + - if: startsWith(github.event.pull_request.head.ref, 'feature') || startsWith(github.event.pull_request.head.ref, 'enhancement') |
| 60 | + uses: actions-ecosystem/action-add-labels@v1 |
| 61 | + with: |
| 62 | + labels: | |
| 63 | + enhancement |
| 64 | + python |
| 65 | +
|
| 66 | + # Style labels |
| 67 | + - if: startsWith(github.event.pull_request.head.ref, 'style') || startsWith(github.event.pull_request.head.ref, 'format') |
| 68 | + uses: actions-ecosystem/action-add-labels@v1 |
| 69 | + with: |
| 70 | + labels: | |
| 71 | + style |
| 72 | + python |
| 73 | +
|
| 74 | + # Build labels |
| 75 | + - if: startsWith(github.event.pull_request.head.ref, 'build') |
| 76 | + uses: actions-ecosystem/action-add-labels@v1 |
| 77 | + with: |
| 78 | + labels: | |
| 79 | + build |
| 80 | +
|
| 81 | + # Dependencies labels |
| 82 | + - if: startsWith(github.event.pull_request.head.ref, 'dependabot') |
| 83 | + uses: actions-ecosystem/action-add-labels@v1 |
| 84 | + with: |
| 85 | + labels: | |
| 86 | + dependencies |
| 87 | + python |
| 88 | +
|
| 89 | + # Documentation labels |
| 90 | + - if: startsWith(github.event.pull_request.head.ref, 'docs') |
| 91 | + uses: actions-ecosystem/action-add-labels@v1 |
| 92 | + with: |
| 93 | + labels: | |
| 94 | + documentation |
| 95 | + python |
| 96 | +
|
| 97 | + # Documentation labels |
| 98 | + - if: startsWith(github.event.pull_request.head.ref, 'refactor') |
| 99 | + uses: actions-ecosystem/action-add-labels@v1 |
| 100 | + with: |
| 101 | + labels: | |
| 102 | + refactor |
| 103 | + python |
| 104 | +
|
| 105 | + # Reopened PR labels |
| 106 | + - if: github.event.action == 'reopened' |
| 107 | + uses: actions-ecosystem/action-add-labels@v1 |
| 108 | + with: |
| 109 | + labels: | |
| 110 | + reopen |
0 commit comments