Skip to content

Commit dc7ff3f

Browse files
authored
fix ci error
1 parent 80dc8f6 commit dc7ff3f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

.github/workflows/label-on-approval.yml

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ name: Add Label on Approval
22

33
on:
44
pull_request_review:
5-
types: [ submitted ]
6-
pull_request:
7-
types: [ opened, synchronize ]
5+
types: [ submitted,edited ]
86

97
jobs:
108
add-label:
@@ -15,21 +13,20 @@ jobs:
1513
uses: actions/checkout@v4
1614

1715
- name: Check if approval is from Collaborators
16+
if: github.event.review.state == 'APPROVED'
1817
id: check_approval
1918
uses: actions/github-script@v7
2019
with:
2120
github-token: ${{ secrets.PAT_TOKEN }}
2221
script: |
2322
const { owner, repo } = context.repo;
24-
const { pull_request, reviews } = context.payload;
23+
const { pull_request, review } = context.payload;
2524
2625
// Define your list of collaborators
2726
const collaborators = ['mxsm', 'TeslaRustor','SpaceXCN']; // Replace with actual GitHub usernames
2827
2928
// 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);
3330
3431
// Return the result to the workflow
3532
return { approvedByCollaborator: isApprovedByCollaborator, pullRequestNumber: pull_request.number };

0 commit comments

Comments
 (0)