File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Label on Approval
2
+
3
+ on :
4
+ pull_request_review :
5
+ types : [ submitted ]
6
+
7
+ jobs :
8
+ add-label-on-approval :
9
+ runs-on : ubuntu-latest
10
+
11
+ steps :
12
+ - name : Checkout repository
13
+ uses : actions/checkout@v2
14
+
15
+ - name : Check for approval and add label
16
+ uses : actions/github-script@v6
17
+ env :
18
+ GITHUB_TOKEN : ${{ secrets.PAT_TOKEN }}
19
+ with :
20
+ script : |
21
+ const approved = context.payload.review.state === 'approved';
22
+ const owner = context.repo.owner;
23
+ const repo = context.repo.repo;
24
+ const pull_number = context.payload.pull_request.number;
25
+
26
+ if (approved) {
27
+ const { data: collaborators } = await github.repos.listCollaborators({ owner, repo });
28
+ const reviewer = context.payload.review.user.login;
29
+ const isOwner = collaborators.some(collab => collab.login === reviewer && collab.permissions.admin);
30
+
31
+ if (isOwner) {
32
+ await github.issues.addLabels({
33
+ owner,
34
+ repo,
35
+ issue_number: pull_number,
36
+ labels: ['approved','auto merge']
37
+ });
38
+ }
39
+ }
You can’t perform that action at this time.
0 commit comments