@@ -2,9 +2,7 @@ name: Add Label on Approval
2
2
3
3
on :
4
4
pull_request_review :
5
- types : [ submitted ]
6
- pull_request :
7
- types : [ opened, synchronize ]
5
+ types : [ submitted,edited ]
8
6
9
7
jobs :
10
8
add-label :
@@ -15,21 +13,20 @@ jobs:
15
13
uses : actions/checkout@v4
16
14
17
15
- name : Check if approval is from Collaborators
16
+ if : github.event.review.state == 'APPROVED'
18
17
id : check_approval
19
18
uses : actions/github-script@v7
20
19
with :
21
20
github-token : ${{ secrets.PAT_TOKEN }}
22
21
script : |
23
22
const { owner, repo } = context.repo;
24
- const { pull_request, reviews } = context.payload;
23
+ const { pull_request, review } = context.payload;
25
24
26
25
// Define your list of collaborators
27
26
const collaborators = ['mxsm', 'TeslaRustor','SpaceXCN']; // Replace with actual GitHub usernames
28
27
29
28
// Check if the review is approved and from a collaborator
30
- const isApprovedByCollaborator = reviews.some(review =>
31
- review.state === 'approved' && collaborators.includes(review.user.login)
32
- );
29
+ const isApprovedByCollaborator = review.state === 'approved' && collaborators.includes(review.user.login);
33
30
34
31
// Return the result to the workflow
35
32
return { approvedByCollaborator: isApprovedByCollaborator, pullRequestNumber: pull_request.number };
0 commit comments