-
-
Notifications
You must be signed in to change notification settings - Fork 628
113 lines (100 loc) · 3.99 KB
/
labeler.yml
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed 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.
#/
# Workflow name:
name: labeler
# Workflow triggers:
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- edited
- review_requested
- review_request_removed
- ready_for_review
- converted_to_draft
# Workflow jobs:
jobs:
# Define a job which automatically labels pull requests based on the contents of the pull request:
labeler:
# Define job name:
name: 'Labeler'
# Only run this job if the pull request did not have label `automated-pr`:
if: contains(github.event.pull_request.labels.*.name, 'automated-pr') == false
# Define job permissions:
permissions:
contents: read
pull-requests: write
# Define the type of virtual host machine:
runs-on: ubuntu-latest
# Define the sequence of job steps:
steps:
# Automatically label pull requests:
- name: 'Automatically label pull requests'
# Pin action to full length commit SHA
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0
with:
configuration-path: .github/labeler.yml
repo-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
# Add "Needs Review" label when PR is opened and not a draft:
- name: 'Add "Needs Review" label if PR is opened and not draft'
if: ${{ github.event.action == 'opened' && github.event.pull_request.draft == false }}
# Pin action to full length commit SHA
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
script: |
await github.rest.issues.addLabels({
'owner': context.repo.owner,
'repo': context.repo.repo,
'issue_number': context.payload.pull_request.number,
'labels': ['Needs Review'],
})
# Add "Needs Review" label when PR is marked ready for review:
- name: 'Add "Needs Review" label if PR is ready for review'
if: ${{ github.event.action == 'ready_for_review' }}
# Pin action to full length commit SHA
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
script: |
await github.rest.issues.addLabels({
'owner': context.repo.owner,
'repo': context.repo.repo,
'issue_number': context.payload.pull_request.number,
'labels': ['Needs Review'],
})
# Remove "Needs Review" label when PR is converted to draft or closed:
- name: 'Remove "Needs Review" label if PR is converted to draft or closed'
if: ${{ github.event.action == 'converted_to_draft' || github.event.action == 'closed' }}
# Pin action to full length commit SHA
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
'owner': context.repo.owner,
'repo': context.repo.repo,
'issue_number': context.payload.pull_request.number,
'name': 'Needs Review',
})
} catch ( error ) {
console.log( 'Error removing label: %s', error.message );
}