-
Notifications
You must be signed in to change notification settings - Fork 1
39 lines (33 loc) · 1.22 KB
/
remove-label-when-approved.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
name: Remove "Ready for review" label on PR approval
on:
pull_request_review:
types: [submitted]
jobs:
remove-label-on-approval:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Remove "Ready for review" label from PR
uses: actions/github-script@v6
with:
script: |
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const labelToRemove = 'Ready for review';
const labels = pullRequest.labels.map(label => label.name);
if (labels.includes(labelToRemove)) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: labelToRemove
});
console.log(`Removed label: ${labelToRemove}`);
} else {
console.log(`Label ${labelToRemove} not found on PR.`);
}