-
-
Notifications
You must be signed in to change notification settings - Fork 105
47 lines (40 loc) · 1.69 KB
/
remove-waiting-for-response.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
40
41
42
43
44
45
46
47
name: Remove 'waiting-for-response' label on issue comment by author
on:
issue_comment:
types: [created]
jobs:
remove-label:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Remove label from issue if comment is from author
uses: actions/github-script@v7
with:
script: |
const commentAuthor = context.payload.comment.user.login;
const labelToRemove = 'waiting-for-response';
const issueData = {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
};
// Get issue details
const { data: issueDetails } = await github.rest.issues.get(issueData);
// Check if the comment author is the issue author
if (issueDetails.user.login === commentAuthor) {
// Get the issue's labels
const { data: labels } = await github.rest.issues.listLabelsOnIssue(issueData);
// Check if the label exists and remove it
if (labels.some(label => label.name === labelToRemove)) {
await github.rest.issues.removeLabel({
name: labelToRemove,
...issueData
});
console.log(`Removed label '${labelToRemove}' from issue #${context.issue.number}`);
} else {
console.log(`Label '${labelToRemove}' not found on issue #${context.issue.number}`);
}
} else {
console.log(`Comment by non-author ${commentAuthor}. No label removed.`);
}