@@ -22,6 +22,18 @@ name: labeler
22
22
# Workflow triggers:
23
23
on :
24
24
pull_request_target :
25
+ types :
26
+ - opened
27
+ - synchronize
28
+ - reopened
29
+ - edited
30
+ - assigned
31
+ - unassigned
32
+ - labeled
33
+ - unlabeled
34
+ - review_requested
35
+ - review_request_removed
36
+ - ready_for_review
25
37
26
38
# Workflow jobs:
27
39
jobs :
53
65
with :
54
66
configuration-path : .github/labeler.yml
55
67
repo-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
68
+
69
+ # Add "Needs Review" label when PR is opened and not a draft:
70
+ - name : ' Add "Needs Review" label if PR is opened and not draft'
71
+ if : ${{ github.event.action == 'opened' && github.event.pull_request.draft == false }}
72
+ # Pin action to full length commit SHA
73
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
74
+ with :
75
+ github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
76
+ script : |
77
+ await github.issues.addLabels({
78
+ 'owner': context.repo.owner,
79
+ 'repo': context.repo.repo,
80
+ 'issue_number': context.payload.pull_request.number,
81
+ 'labels': ['Needs Review'],
82
+ })
83
+
84
+ # Add "Needs Review" label when PR is marked ready for review:
85
+ - name : ' Add "Needs Review" label if PR is ready for review'
86
+ if : ${{ github.event.action == 'ready_for_review' }}
87
+ # Pin action to full length commit SHA
88
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
89
+ with :
90
+ github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
91
+ script : |
92
+ await github.issues.addLabels({
93
+ 'owner': context.repo.owner,
94
+ 'repo': context.repo.repo,
95
+ 'issue_number': context.payload.pull_request.number,
96
+ 'labels': ['Needs Review'],
97
+ })
98
+
99
+ # Remove "Needs Review" label when PR is converted to draft or closed:
100
+ - name : ' Remove "Needs Review" label if PR is converted to draft or closed'
101
+ if : ${{ github.event.action == 'converted_to_draft' || github.event.action == 'closed' }}
102
+ # Pin action to full length commit SHA
103
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
104
+ with :
105
+ github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
106
+ script : |
107
+ try {
108
+ await github.issues.removeLabel({
109
+ 'owner': context.repo.owner,
110
+ 'repo': context.repo.repo,
111
+ 'issue_number': context.payload.pull_request.number,
112
+ 'name': 'Needs Review',
113
+ })
114
+ } catch ( error ) {
115
+ console.log( 'Error removing label: %s', error.message );
116
+ }
0 commit comments